c# - Accented characters displayed as hex values in mail source file -
i have convert content of mail message xml format facing encoding problems. indeed, accented characters , others displayed in message file hex value. ex :
é displayed =e9, ô displayed =f4, = displayed =3d...
the mail configured sent iso-8859-1 coding , can see these parameters in file :
content-type: text/plain; charset=iso-8859-1 content-transfer-encoding: quoted-printable
notepad++ detects file "ansi utf-8".
i need convert in c# (i in script task in ssis project) readable , can not manage that.
i tried encoding in utf-8 in streamreader nothing. despite readings on topic, still not understand steps lead problem , means solve it.
i point out outlook decodes message , accented characters displayed correctly.
thanks in advance.
ok looking on wrong direction. keyword here "quoted-printable". issue comes , have decode.
in order that, followed example posted martin murphy in thread :
c#: class decoding quoted-printable encoding?
the method described :
public static string decodequotedprintables(string input) { var occurences = new regex(@"=[0-9a-f]{2}", regexoptions.multiline); var matches = occurences.matches(input); foreach (match match in matches) { char hexchar= (char) convert.toint32(match.groups[0].value.substring(1), 16); input =input.replace(match.groups[0].value, hexchar.tostring()); } return input.replace("=\r\n", ""); }
to summarize, open streamreader in utf8 , place each read line in string :
mystring += line + "\r\n";
i open streamwriter in utf8 , write mystring variable decoded in :
mystreamwriter.writeline(decodequotedprintables(mystring));
Comments
Post a Comment