Convert a unicode String In C++ To Upper Case

后端 未结 9 2097
予麋鹿
予麋鹿 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 14:51

    For C I would use toupper after adjusting the C locale in the current thread.

    setlocale(LC_CTYPE, "en_US.UTF8");
    

    For C++ I would use the toupper method of std::ctype:

    std::locale loc;
    
    auto& f = std::use_facet>(loc);
    
    char str[80] = "Hello World";
    
    f.toupper(str, str+strlen(str));
    

提交回复
热议问题