I use Visual Studio 2010, C# to read Gmail inbox using IMAP
, it works as a charm, but I think Unicode is not fully supported as I cannot get Persian (Farsi) strings easily.
For instance I have my string: سلام
, but IMAP
gives me: "=?utf-8?B?2LPZhNin2YU=?="
.
How can I convert it to original string? any tips from converting utf-8 to string?
Let's have a look at the meaning of the MIME encoding:
So, to decode this, take the
...something...
out of your string (2LPZhNin2YU=
in your case) and thenreverse the Base64 encoding
interpret the bytes as a UTF8 string
text
should now contain the desired result.A description of this format can be found in Wikipedia:
here he is
What you have is a MIME encoded string. .NET does not include libraries for MIME decoding, but you can either implement this yourself or use a library.