Posted
Filed under C#
UNICODE와 한글 처리 BYTE
모든 문자를 유니코드로 처리하는 닷넷 프레임워크상에서
한글 문자열을 2바이트로 처리해서 원하는 바이트 길이만큼 자르는 방식이 필요하다.

[SAMPLE]
String line = "가나다라마";
char[] charData = new char[1024];
byte[] byteData = new byte[1024];
System.Text.Encoding myEncoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987");

올바른
byteData = myEncoding.GetBytes(line); // 길이가 10 byte 생성
//byteData.GetLength(0) 결과는 10이다
2009/07/17 19:12 2009/07/17 19:12