轉換 Big5 字元
Big5 依傳入內碼轉成字元
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | byte[] big5Bytes = new byte[2];
 
 
 string big5Code = "A2AF";
 
 
 big5Bytes[0] = (byte)Convert.ToInt32(big5Code.Substring(0, 2), 16);
 
 
 big5Bytes[1] = (byte)Convert.ToInt32(big5Code.Substring(2, 2), 16);
 
 
 Encoding big5 = Encoding.GetEncoding(950);
 
 
 string result = big5.GetString(big5Bytes);
 
 | 
轉換 Unicode 字元
Unicode 依傳入內碼轉成字元,與 Big5 轉換的方法雷同,只需調整內碼放置的順序
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | byte[] unicodeBytes = new byte[2];
 
 
 string unicodeCode = "FF10";
 
 
 unicodeBytes[0] = Convert.ToByte(unicodeCode.Substring(2, 2), 16);
 
 
 unicodeBytes[1] = Convert.ToByte(unicodeCode.Substring(0, 2), 16);
 
 
 Encoding unicode = Encoding.Unicode;
 
 
 string result = unicode.GetString(unicodeBytes);
 
 |