How to convert UTF-8 std::string to UTF-16 std::wstring?

后端 未结 6 802
挽巷
挽巷 2020-11-29 07:21

If I have a UTF-8 std::string how do I convert it to a UTF-16 std::wstring? Actually, I want to compare two Persian words.

6条回答
  •  半阙折子戏
    2020-11-29 07:51

    Microsoft has developed a beautiful library for such conversions as part of their Casablanca project also named as CPPRESTSDK. This is marked under the namespaces utility::conversions.

    A simple usage of it would look something like this on using namespace

    utility::conversions

    utf8_to_utf16("sample_string");
    

提交回复
热议问题