How to make case-insensitive comparison between two Unicode characters or strings under Windows in C / C ++?

I am looking for a way to make a non-sensitive comparison of two Unicode characters (char32) under Windows (C / C ++, not .NET).

I know that the solution must know the locale.

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

+3
source share
2 answers

My first thought is what you should look for CompareStringExwith its parameters LOCALE_INVARIANTand NORM_IGNORECASE.

+2
source

Oops, 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)

( UTF-16), ( UTF-8).

_setmbcp(int codepage)
0

Source: https://habr.com/ru/post/1735954/


All Articles