case insensitive strings compare
Posted on 2003-03-02
Recently, I've encountered a problem of comparing 2 strings containing German special symbols, like "oäüß"
and "ÖÄÜß". Inside the code i reffer to strings as usual ANSI. I used _stricmp - it doesn't work of course, then I tred to translate strings to Unicode and compare them:
char* ch1 = "oäüß";
char* ch2 = "ÖÄÜß";
int len1 = strlen(ch1);
int len2 = strlen(ch2);
int nCodePage = 1252;//(I tried also CP_ACP = 0)
MultiByteToWideChar(nCodePage, 0, ch1, len1, mbt_out1, len1);
MultiByteToWideChar(nCodePage, 0, ch2, len2, mbt_out2, len2);
int nCompRes = wcsicmp(mbt_out1, mbt_out2);
Nothing works, i.e. nCompRes != 0. My Windows is not German, but German language is installed.
Please, help who can. Thnx in advance.