Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 case insensitive comparison of beginning of a string (unicode)

I have to check if the particular string begins with another one. Strings are encoded using utf8, and a comparison should be case insensitive.

I know that this is very similar to that topic Case insensitive string comparison in C++ but I do not want to use the boost library and I prefer portable solutions (If it is 'nearly' impossible, I prefer Linux oriented solutions).

Is it possible in C++11 using its regexp library? Or just using simple string compare methods?

like image 564
Dejwi Avatar asked May 04 '12 07:05

Dejwi


1 Answers

The only way I know of that is UTF8/internationalization/culture-aware is the excellent and well-maintained IBM ICU: International Components for Unicode. It's a C/C++ library for *nix or Windows into which a ton of research has gone to provide a culture-aware string library, including case-insensitive string comparison that's both fast and accurate.

IMHO, the two things you should never write yourself unless you're doing a thesis paper are encryption and culture-sensitive string libraries.

like image 195
Mahmoud Al-Qudsi Avatar answered Sep 19 '22 20:09

Mahmoud Al-Qudsi