views:

124

answers:

2

I'm looking for a way of doing a insensitive compare of two Unicode characters (char32) under Windows (C/C++, not .NET).

I am aware that the solution is supposed to be locale aware.

I would like a solution that would not require additional third-party libraries.

+2  A: 

My first thought is that you should lookup CompareStringEx with its parameters LOCALE_INVARIANT and NORM_IGNORECASE.

Johann Gerell
A: 

Whoops, you want to compare char32s. Ignore my post.

My original answer

For posterity:

You can use

_wcsicmp(const wchar_t *string1, const wchar_t *string2) or

_mbsicmp(const unsigned char_t *string1, const unsigned char *string2)

the former compares wide characters (usually UTF-16) and the latter compares multi-byte characters (usually UTF-8). You need to set the code page using

_setmbcp(int codepage)
Niki Yoshiuchi
char32 is 32bit (UTF-32), wchar_t is 16 bits (UTF16-LE).
Sorin Sbarnea
wchar_t is UCS-2 for all practical purposes. The widestring functions don't treat widestring as variable character length; that's the whole point of having them.
Seva Alekseyev