Asp.net에서 작업 도중 한글 사이즈를 구할 때
숫자와 영문은 1byte 한글은 2byte로 길이를 체크해야 할때가 있다.

그때 사용할 수 있는 코드

System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987");

byte[] HanByte = encoding.GetBytes("한글 문자열");

 

HanByte.length 하면 길이를 가져올 수 있다.