I have googled on this topic and I have looked at every answer, but I still don't get it.
Basically I need to convert UTF-8 string to ISO-8859-1 and I do it using following code:
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
Encoding utf8 = Encoding.UTF8;
string msg = iso.GetString(utf8.GetBytes(Message));
My source string is
Message = "ÄäÖöÕõÜü"
But unfortunately my result string becomes
msg = "�ä�ö�õ�ü
What I'm doing wrong here?
Encoding.Unicode
and in the Win32 API. Unicode is a character set, not an encoding. UTF-16 is one of several encodings for Unicode.) – Tom BlodgetMessage
was decoded from UTF-8. Assuming that part worked correctly, converting to Latin-1 is as simple asbyte[] bytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(Message)
. Then, like StuS says, you can convert the Latin-1 bytes back to UTF-16 withEncoding.GetEncoding("ISO-8859-1").GetString(bytes)
– Qwertie