mika_soukhov
2012-07-09T13:39:24Z
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
2012-07-12T03:49:53Z
I cannot seem to find another reliable method. char is 2 bytes (so utf-16). This should work.
mika_soukhov
2012-07-13T19:26:50Z
Originally Posted by: Jaben 

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



http://forum.yetanotherf...il-issues.aspx#post55427 
alpha6789
2012-07-19T16:06:40Z
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.yetanotherf...il-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<char>(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
2012-07-19T16:34:21Z
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
2012-07-19T17:24:33Z
Further investigation finds it's because the XmlSerializer doesn't deserialize the streamReader object correctly. it only parses new line as \n.

Yucks.

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

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved