Jump to content
  • Advertisement
Sign in to follow this  
vladic2000x

wcsicmp fails

This topic is 3253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to compare without taking into account the case of the characters, two russian strings, and the "_wcsicmp" function returns -2, which means different. if(_wcsicmp(L"3 Мяч",L"3 мяч")!=0) { assert(0); } does anyone give me a hint?

Share this post


Link to post
Share on other sites
Advertisement
Have you set the appropriate locale before making the comparison?

Doing this before the comparison makes it pass for me (apologies if this isn't the right locale setting, just guessing):
setlocale(LC_CTYPE, "rus");

Share this post


Link to post
Share on other sites
That's terrible... How would I know that I need to set the locale? Nothing about that in MSDN and I thought that the wide string version are universal..

Thanks mattd.

Share this post


Link to post
Share on other sites
Quote:
Original post by vladic2000x
That's terrible... How would I know that I need to set the locale? Nothing about that in MSDN and I thought that the wide string version are universal..


It does say in the MSDN:
Quote:
Remarks
The _stricmp function lexicographically compares lowercase versions of string1 and string2 and returns a value indicating their relationship. _stricmp differs from _stricoll in that the _stricmp comparison is affected by LC_CTYPE, whereas the _stricoll comparison is according to the LC_CTYPE and LC_COLLATE categories of the current locale. For more information on the LC_COLLATE category, see setlocale and Locale Categories.

Share this post


Link to post
Share on other sites
It's impossible to create a universal case insensitive comparison, since different languages have different rules for cases. For example, in some languages the upper case of ü is Ü, but in others it's UE.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!