Convert a unicode String In C++ To Upper Case

后端 未结 9 2094
予麋鹿
予麋鹿 2020-12-01 14:51

How we can convert a multi language string or unicode string to upper/lower case in C or C++.

9条回答
  •  自闭症患者
    2020-12-01 15:01

    If you want a sane and mature solution, look at IBM's ICU. Here's an example:

    #include 
    #include 
    #include 
    
    int main(){
        icu::UnicodeString us("óóßChloë");
        us.toUpper(); //convert to uppercase in-place
        std::string s;
        us.toUTF8String(s);
        std::cout<<"Upper: "<

    Output:

    Upper: ÓÓSSCHLOË
    Lower: óósschloë
    

    Note: In the later step SS isn't being treated as capital of German ß

提交回复
热议问题