YAFLogo

mika_soukhov
11 years ago
It seems that the code

public static bool ContainsUnicodeCharacter(string input)
{
    return input.ToCharArray().Any<char>(c => (c > '\x00ff'));
}

can not correctly identify the correct character encoding for Russian (uses charset="utf-16" instead of utf 😎. Is the any other way to set directly encoding for all messages?

v1.9.6.1
Sponsor

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
11 years ago
I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work.
mika_soukhov
11 years ago
Originally Posted by: Jaben 

I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work.



http://forum.yetanotherforum.net/yaf_postsm55427_Few-email-issues.aspx#post55427 
alpha6789
11 years ago
Originally Posted by: mika_soukhov 

Originally Posted by: Jaben 

I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work.



http://forum.yetanotherforum.net/yaf_postsm55427_Few-email-issues.aspx#post55427 



I am using non-english culture and also facing the same issue. I also did the following modification

public static bool ContainsUnicodeCharacter(string input)
{
return input.ToCharArray().Any(c => (c > '\x00ff'));
}


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.
alpha6789
11 years ago
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.
alpha6789
11 years ago
Further investigation finds it's because the XmlSerializer doesn't deserialize the streamReader object correctly. it only parses new line as \n.

Yucks.
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button