Convert wstring to string encoded in UTF-8

前端 未结 6 1104
囚心锁ツ
囚心锁ツ 2020-11-29 04:19

I need to convert between wstring and string. I figured out, that using codecvt facet should do the trick, but it doesn\'t seem to work for utf-8 locale.

My idea is,

6条回答
  •  情话喂你
    2020-11-29 04:35

    You can use boost's utf_to_utf converter to get char format to store in std::string.

    std::string myresult = boost::locale::conv::utf_to_utf(my_wstring);
    

提交回复
热议问题