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?
Use Encoding.Convert to adjust the byte array before attempting to decode it into your destination encoding.
Encoding iso = Encoding.GetEncoding("ISO-8859-1"); Encoding utf8 = Encoding.UTF8; byte utfBytes = utf8.GetBytes(Message); byte isoBytes = Encoding.Convert(utf8, iso, utfBytes); string msg = iso.GetString(isoBytes);