轉自 https://dotblogs.com.tw/yc421206/archive/2011/06/09/27596.aspx
foreach (EncodingInfo ei in Encoding.GetEncodings())
{
Encoding e = ei.GetEncoding();
Console.WriteLine("Name:{0},CodePage:{1}",ei.Name, e.CodePage);
}
轉自 https://goo.gl/Xgh24y
重新解碼在編碼,以解決亂碼問題
StringBuilder sb = new StringBuilder();
string source = "hello 浣犲ソ";
foreach (var e1 in Encoding.GetEncodings())
{
foreach (var e2 in Encoding.GetEncodings())
{
byte[] unknow = Encoding.GetEncoding(e1.CodePage).GetBytes(source);
string result = Encoding.GetEncoding(e2.CodePage).GetString(unknow);
sb.AppendLine(string.Format("{0} => {1} : {2}", e1.CodePage, e2.CodePage, result));
}
}
File.WriteAllText("test.txt", sb.ToString());
0 意見:
張貼留言