Which tolower in C++?

前端 未结 3 980
小鲜肉
小鲜肉 2020-12-11 00:37

Given string foo, I\'ve written answers on how to use cctype\'s tolower to convert the characters to lowercase

transform(cbegin(foo         


        
3条回答
  •  抹茶落季
    2020-12-11 01:17

    Unfortunately,both are equally bad. Although std::string pretends to be a utf-8 encoded string, non of the methods/function (including tolower), are really utf-8 aware. So, tolower / tolower + locale may work with characters which are single byte (= ASCII), they will fail for every other set of languages.

    On Linux, I'd use ICU library. On Windows, I'd use CharUpper function.

提交回复
热议问题