庫將unicode字符串存儲爲。使用unicode字符串作爲std :: vector <unsigned short>
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
你確定它們不是UTF-16字符串嗎?將UTF-8存儲爲'unsigned short'向量在典型平臺上浪費了50%的空間。 –
你確定他們不只是*代碼點*嗎? – Dabbler
圖書館的名稱是什麼? ustring到wstring應該沒有問題,因爲wstring是wchar_ts,它也應該是短小的。如果您希望保留內容,那麼在使用字符串或字符時,您可能需要將UTF-16轉換爲UTF-8。如果你需要從char到ustring,你需要轉換字符。看看libaray ICU。 – RedX