我有smalll問題,我想的Unicode轉換成多字節有什麼辦法的Unicode轉換爲多字節
5
A
回答
7
std::string NarrowString(const std::wstring& str, const char* localeName = "C")
{
std::string result;
result.resize(str.size());
std::locale loc(localeName);
std::use_facet<std::ctype<wchar_t> >(loc).narrow(
str.c_str(), str.c_str() + str.size(), '?', &*result.begin());
return result;
}
應該使用當前區域設置將Unicode字符串轉換。對於不屬於代碼頁的字符,'?'正在使用caracter。使用Visual C++ 2005/2008進行測試。
+0
很好,但如何檢測它是否成功轉換或'?'被用於角色?往返轉換? – Narek 2012-11-20 07:55:55
3
wcstombs精美的作品對我來說:)
0
有WideCharToMultiByte WINAPI功能。
5
三個選項的副手:
+0
+1對於良好的資源。你能分享任何資源轉換反向嗎?意味着從多字節到Unicode? – 2013-10-03 08:55:35
1
在大多數情況下,調用WideCharToMultiByte()就足夠了。
0
相關問題
- 1. 從多字節編碼轉換爲Unicode
- 2. 使用部分緩衝區將多字節Unicode字節數組轉換爲NSString
- 3. PHP - Unicode轉換爲字符
- 4. 將漢字轉換爲Unicode
- 5. 將Unicode轉換爲字符
- 6. 將錯誤的unicode字符串轉換爲字節
- 7. 轉換八位字節字符串轉換爲Unicode字符串,Python 3中
- 8. 將unicode字符串轉換爲字節字符串
- 9. 在將UNICODE字符轉換爲UTF-8多字節字符時感到困惑
- 10. 如何將unicode JavaScript字符串轉換爲字節數組?
- 11. 如何蟒蛇Unicode字符串轉換爲字節
- 12. Unicode轉換爲字符串葉字節Byte命令標記
- 13. C#將字符串Unicode轉換爲字節Ansi
- 14. 將Unicode字符串轉換爲字節數組
- 15. 從Unicode轉換爲單字節字符集
- 16. 轉換的字節數組爲UTF-8的unicode
- 17. 轉換非Unicode爲Unicode
- 18. 如何將十六進制字節轉換爲Java中的Unicode
- 19. 如何將字節(UTF-8)轉換爲PHP中的Unicode?
- 20. 字符串轉換爲字節轉換
- 21. 在Unicode中將unicode字符串轉換爲可用的unicode
- 22. 將字符串中的多個Unicode轉換爲字符
- 23. 轉換KOI8-R XML節點轉換爲Unicode在C#
- 24. 的Unicode字符轉換爲UTF-8 PHP
- 25. Unicode轉換爲Java中的字符串
- 26. 如何將包含unicode字符的字符串轉換爲unicode?
- 27. 在MySQL中將複合字節轉換爲Unicode
- 28. 如何將unicode字節序列轉換爲XML實體?
- 29. 字符串轉換爲字節[]和轉換字節[]串
- 30. 將字節轉換爲字節[]
你檢查過wcstombs嗎? http://www.cplusplus.com/reference/clibrary/cstdlib/wcstombs/ – vpram86 2009-10-06 13:12:31
我想你需要給我們更多的細節。你現在有什麼unicode格式,你想使用哪種多字節編碼? – 2009-10-06 13:12:37