본문 바로가기

IT/Dot Net

중국어 간자체 변환

  
  
Public Function ToSCUnicode(ByVal str As String) As String
  Dim arrByte_GBK As Byte()
  Dim arrByte_UTF16 As Byte()
  Dim strUTF16 As String

  ' 현재 시스템 인코딩
  Dim _defaultEncoding As Encoding = System.Text.Encoding.GetEncoding(0)
  ' Chinese Simplified (GB2312)
  Dim encGBK As System.Text.Encoding = System.Text.Encoding.GetEncoding(936)
  ' UTF - 16
  Dim encUTF16 As System.Text.Encoding = System.Text.Encoding.Unicode()

  ' 현재 시스템 인코딩에서 받은 문자열을 Chinese Simplified (GB2312) 로 바이트로 변경
  arrByte_GBK = _defaultEncoding.GetBytes(str)
  ' 다시 UTF-16 으로 변환
  arrByte_UTF16 = System.Text.Encoding.Convert(encGBK, encUTF16, arrByte_GBK)
  ' 문자열로 추출
  strUTF16 = encUTF16.GetString(arrByte_UTF16)
  Return strUTF16
 End Function