When I tried tolower() with non english charecters in c++ it's not working normally. I searched that issue and I came across something about locale but I am not sure about best solution of that.
My sample code is below:
printf("%c ",tolower('Ü'));
Unfortunately, the standard C++ library does not have sufficient support for changing the case of all possible non-English characters (in so far as those characters that have case variants at all). This limitation is caused by the fact that the C++ standard assumes that a single character and its case variants occupy exactly one char
object (or wchar_t
object for wide characters) and for non-English characters that is not guaranteed to be true (also depending on how the characters are coded).
If your environment uses a single-byte encoding for the relevant characters, this might give you what you want:
std::cout << std::tolower('Ü', locale());
With wide characters, you will probably have more luck:
std::wcout << std::tolower(L'Ü', locale());
but even that won't give the correct result for toupper(L'ß')
, which would be the two-character sequence L"SS"
).
If you need support for all characters, take a look at the ICU library, in particular the part about case mappings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With