我尝试过在谷歌上搜索,但无法找到以下文本所属的字符集:
具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½®
但是将<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
放入HTML文件中并保留这个字符串,我就能够正确地查看中文字符了:
具有靜電產生裝置之影像輸入裝置
所以我的问题是:
我可以使用哪些工具检测此文本的字符集?
我该如何在C#中正确地转换/编码/解码它们?
更新: 出于完整性考虑,我已更新此测试。
[TestMethod]
public void TestMethod1()
{
string encodedText = "具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½®";
Encoding utf8 = new UTF8Encoding();
Encoding window1252 = Encoding.GetEncoding("Windows-1252");
byte[] postBytes = window1252.GetBytes(encodedText);
string decodedText = utf8.GetString(postBytes);
string actualText = "具有靜電產生裝置之影像輸入裝置";
Assert.AreEqual(actualText, decodedText);
}
}