I am really having trouble with encoding characters.
The application I am creating i based on a NNTP component from Smilla
smilla.ru
My propblem is when I read a string which contain special characters and the character is set to utf-8. It works fine with iso-8859-1 strings (I think)
The problem occurs whene case below is Q, encoding is set to utf-8,
s= "=?Utf-8?Q?M=C3=A1scara_WindowsForm?="
the return value of this function is:
"Máscara_WindowsForm"
it should be:
Máscara WindowsForm
I hope someone can help. I am really frustrated...have already used many days om this problem...
Here is the code I am using:
public static string DecodeHeaderString(string s)
{
Match header = Regex.Match(s, @"=\?(.+)\?(.+)\?(.+)\?=");
if (header.Success)
{
string charset = header.Groups[1].Value;
string encoding = header.Groups[2].Value;
string text = header.Groups[3].Value;
switch (encoding)
{
case "B":
text = Encoding.Default.GetString(Convert.FromBase64Strin g(text));
break;
case "Q":
text = Encoding.Default.GetString(FromQuotedPrintableStri ng(text));
break;
}
text = Charset.Decode(charset, text, false);
return text;
}
else
return s;
}
Encoding issue - utf-8?
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.8 Final
Web @
http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -