YAFLogo

Posted by: mika_soukhov - Monday, 9 July 2012 15:39:24
It seems that the code [code=csharp]public static bool ContainsUnicodeCharacter(string input) { return input.ToCharArray().Any(c => (c > '\x00ff')); }[/code] can not correctly identify the correct character encoding for Russian (uses charset="utf-16" instead of utf 8). Is the any other way to set directly encoding for all messages? v1.9.6.1

Posted by: Jaben - Thursday, 12 July 2012 05:49:53
I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work.

Posted by: mika_soukhov - Friday, 13 July 2012 21:26:50
[quote=Jaben;55444]I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work. [/quote] It seems encoding issue doesn't related with UTF-16, cause html mails also sends as UTF-16, but it looks ok. BTW, I've fixed it by using html instead of plain text http://forum.yetanotherforum.net/yaf_postsm55427_Few-email-issues.aspx#post55427

Posted by: alpha6789 - Thursday, 19 July 2012 18:06:40
[quote=mika_soukhov;55460][quote=Jaben;55444]I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work. [/quote] It seems encoding issue doesn't related with UTF-16, cause html mails also sends as UTF-16, but it looks ok. BTW, I've fixed it by using html instead of plain text http://forum.yetanotherforum.net/yaf_postsm55427_Few-email-issues.aspx#post55427[/quote] I am using non-english culture and also facing the same issue. I also did the following modification [i]public static bool ContainsUnicodeCharacter(string input) { return input.ToCharArray().Any(c => (c > '\x00ff')); }[/i] and used Encoding.Default instead of Encoding.UTF8, still got the messy message body. I found the problem is because the input string contains \n instead of \r\n. Really wonder why.

Posted by: alpha6789 - Thursday, 19 July 2012 18:34:21
Very interestingly, I tested on another machine, it shows the normal \r\n. Not sure if it's database problem or the operating system problem.

Posted by: alpha6789 - Thursday, 19 July 2012 19:24:33
Further investigation finds it's because the XmlSerializer doesn't deserialize the streamReader object correctly. it only parses new line as \n. Yucks.