How to encode and decode chinese characters?
- by melaos
I've try googling around but wasn't able to find what charset that this text below belongs to:
具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½®
But putting <meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
and keeping that string into a html file i was able to view the chinese character wording properly.
which is:
???????????????
So my question is:
what tools can i use to detect the character set of those text?
And how do i convert/encode/decode them properly in C#?
Updates:
Added some test code
[TestMethod]
public void TestMethod1()
{
string encodedText = "具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½®";
Encoding encoder = new UTF8Encoding();
byte[] postBytes = encoder.GetBytes(encodedText);
postBytes = UTF8Encoding.Convert(Encoding.UTF8, Encoding.Unicode, postBytes);
string decodedText = Encoding.Unicode.GetString(postBytes);
Assert.AreNotEqual(encodedText, decodedText);
}
thanks