String 스트링 Byte 변환

c# 2025. 1. 20. 12:31
728x90
string temp1 = "점심시간";
string temp2 = "123";

byte[] unibytes = Encoding.Unicode.GetBytes(temp1);
byte[] unibytes = Encoding.Unicode.GetBytes(temp2);

unicode 인코딩 한글 한자당 2Byte, unibytes.Length = 8 출력

"123" 당연 문자열 취급 Length = 6 출력

 

string temp1 = "점심시간";

byte[] Defbytes = Encoding.Default.GetBytes(temp1);

Default로 인코딩 시 UTF8 한글 한자당 3Byte, Defbytes.Length = 12 출력.

728x90
Posted by 바르마스
,