[問題] Big5 轉 UTF-8

作者: FT6034 (耐心等待)   2015-06-14 14:55:30
byte[] byt = Encoding.GetEncoding(950).GetBytes(args.Message);
string utf8Str = Encoding.GetEncoding(65001).GetString(byt); //UTF-8
Console.WriteLine(utf8Str);
請教一下
為什麼只有部分中文字轉碼成功? @@"a
當 args.Message = "測試" -> utf8Str= "測試"
當 args.Message = "中文字" -> utf8Str= "中????"
當 args.Message = "測"   -> utf8Str= "??"
當 args.Message = "試"   -> utf8Str= "??"
當 args.Message = "測試12345中文字abd中" -> utf8Str="測試12345中??字abd??"
作者: soup514   2015-06-14 16:04:00
沒做Encoding.Convert
作者: fo40225   2015-06-14 22:58:00
var newByt = Encoding.Convert(Encoding.GetEncoding(950), Encoding.UTF8, byt);var utf8Str = Encoding.GetEncoding(65001).GetString(newByt);
作者: leicheong (睡魔)   2015-06-15 20:57:00
Console的Unicode支援有問題的. 寫進檔案再開來看吧.

Links booklink

Contact Us: admin [ a t ] ucptt.com