日期:2014-05-19  浏览次数:21498 次

如何将Shift-JIS编码转换为字符?
我需要将Shift-JIS编码[8140-EAA4]转换为对应的字符。
例如:
88A0   ->   唖
88A1   ->   娃
88A2   ->   阿

------解决方案--------------------
据说可以这样
用gedit!
打开中文文件,然后save as,在对话框里选Character Coding里面的Add or Remove,再选shift_jis编码,存盘,就行了。
------解决方案--------------------
http://msdn2.microsoft.com/en-us/library/aa332096(VS.71).aspx
------解决方案--------------------
Encoding encoding = Encoding.GetEncoding( "Shift-JIS ");
string s = "88A0 ";
byte[] bytes = new byte[s.Length / 2];
for (int i = 0, j = 0; i < s.Length; i += 4, j += 2)
{
bytes[j] = Convert.ToByte(s.Substring(i, 2), 16);
bytes[j + 1] = Convert.ToByte(s.Substring(i + 2, 2), 16);
}
string temp = encoding.GetString(bytes);
------解决方案--------------------
Decoder decoder = Encoding.GetEncoding(932).GetDecoder();
char[] c = new char[1];
decoder.GetChars(new byte[] { 0x88, 0xA1 }, 0, 2, c, 0);
Console.WriteLine(c[0]);