库将 unicode 字符串存储为。
std::vector<unsigned short> ustring;
我如何以可移植的方式进行这些转换?
convert ustring to std::wstring;
convert ustring to std::string;
convert ustring to std::vector<unsigned char>;
convert std::vector<unsigned char> to ustring;
编辑
字符串可能是 UTF-16 而不是 UTF-8
最佳答案
libiconv , icu , UTF8-CPP ,其他人可以做到这一点。 AFAIK,C++ 没有在 UTF8/16/32 之间转换的可移植方式。请记住,std::wstring
在某些系统上是 UTF16,而在其他系统上是 UTF32。
关于c++ - 使用 unicode 字符串作为 std::vector<unsigned short>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7968877/