Stumped with Unicode, Boost, C++, codecvts

后端 未结 3 643
感情败类
感情败类 2020-12-28 09:42

In C++, I want to use Unicode to do things. So after falling down the rabbit hole of Unicode, I\'ve managed to end up in a train wreck of confusion, headaches and locales.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-28 09:45

      std::cout.imbue(convLoc);
      std::cout << data << std::endl;
    

    This does no conversion, since it uses codecvt which is a no-op. The only standard streams that use codecvt are file-streams. std::cout is not required to perform any conversion at all.

    To force Boost.Filesystem to interpret narrow-strings as UTF-8 on windows, use boost::filesystem::imbue with a locale with a UTF-8 ↔ UTF-16 codecvt facet. Boost.Locale has an implementation of the latter.

提交回复
热议问题