How do I get STL std::string to work with unicode on windows?

前端 未结 9 2088
猫巷女王i
猫巷女王i 2021-02-04 13:29

At my company we have a cross platform(Linux & Windows) library that contains our own extension of the STL std::string, this class provides all sort of functionality on top

9条回答
  •  无人及你
    2021-02-04 13:54

    There are several misconceptions in your question.

    • Neither C++ nor the STL deal with encodings.

    • std::string is essentially a string of bytes, not characters. So you should have no problem stuffing UTF-8 encoded Unicode into it. However, keep in mind that all string functions also work on bytes, so myString.length() will give you the number of bytes, not the number of characters.

    • Linux is not inherently UTF-8. Most distributions nowadays default to UTF-8, but it should not be relied upon.

提交回复
热议问题