hello
how can i convert a string in utf8 to iso-8859-1?
i have a string that haves something like this:"=?iso-8859-1?Q?Valida=E7=E3o_da?=" and i would like to convert this to readble text.
Thanks in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AlanPosted Oct 2, 2008, 12:17 PM
What you've got there is MIME encoded-word syntax using the Q-encoding, which is a variation of the quoted-printable encoding.
Broadly speaking, printable ASCII characters are printed normally, a space is represented by an underscore and everything else is represented in the form '= XX' where XX is the hexadecimal representation of the character number in whatever encoding is specified.
So, using iso-8859-1 (code page 28591), I think the normal text equivalent of your example string would be: Validação da
See these links for further details:
http://en.wikipedia.org/wiki/MIME
http://en.wikipedia.org/wiki/Quoted-printable
http://www.faqs.org/rfcs/rfc2047.html
If you have a lot of these strings to translate, then there appear to be commercial decoders available but I don't think there's anything in the .NET framework and I couldn't find any free C# utilities (I translated the above string by hand from the table below). However, it might not be too difficult to write a decoder using a regular expression if you can fully understand the specification.
http://en.wikipedia.org/wiki/ISO_8859-1