转 C++11与Unicode及使用标准库进行UTF-8、UTF-16、UCS2、UCS4/UTF-32编码转换 utf8转utf16 utf16转utf8
2016-08-03 11:19
501 查看
http://www.cppblog.com/Error/archive/2014/09/25/208413.html
// utf-8
char u8_array[] = u8"破晓的博客";
std::string u8_str = u8"破晓的博客";
// utf-16
char16_t u16_c = u'中';
char16_t u16_array[] = u"破晓的博客";
std::u16string u16_str = u"破晓的博客";
// ucs4
char32_t u32_c = U'破';
char32_t u32_array[] = U"破晓的博客";
std::u32string u32_str = U"破晓的博客";
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf8_ucs4_cvt;
std::u32string ucs4_cvt_str = utf8_ucs4_cvt.from_bytes(u8_source_str);
// utf-8
char u8_array[] = u8"破晓的博客";
std::string u8_str = u8"破晓的博客";
// utf-16
char16_t u16_c = u'中';
char16_t u16_array[] = u"破晓的博客";
std::u16string u16_str = u"破晓的博客";
// ucs4
char32_t u32_c = U'破';
char32_t u32_array[] = U"破晓的博客";
std::u32string u32_str = U"破晓的博客";
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf8_ucs4_cvt;
std::u32string ucs4_cvt_str = utf8_ucs4_cvt.from_bytes(u8_source_str);
相关文章推荐
- C++11与Unicode及使用标准库进行UTF-8、UTF-16、UCS2、UCS4/UTF-32编码转换
- C++11与Unicode及使用标准库进行UTF-8、UTF-16、UCS2、UCS4/UTF-32编码转换
- C++11与Unicode及使用标准库进行UTF-8、UTF-16、UCS2、UCS4/UTF-32编码转换
- 彻底搞清楚字符编码: ASCII, ISO_8859, GB2312,UCS, Unicode, UTF8.(GBK, GB18030, BIG5, UTF-7,UTF-16,UTF-32)
- C++11之后,对源代码增加了UTF8和UCS4的支持(Windows内部使用Unicode,因为nt内核用的是ucs2,那是89年,utf8到了92年才发明出来)
- 彻底搞清楚字符编码: ASCII, ISO_8859, GB2312,UCS, Unicode, UTF8.(GBK, GB18030, BIG5, UTF-7,UTF-16,UTF-32) .
- 彻底搞清楚字符编码: ASCII, ISO_8859, GB2312,UCS, Unicode, UTF8.(GBK, GB18030, BIG5, UTF-7,UTF-16,UTF-32)
- Unicode,utf-8,utf-16,utf-32,ucs16,ucs32关系
- 字符编码笔记:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian
- php读取淘宝数据包csv文件 unicode ucs-2 utf-16 中文乱码问题解决
- 字符编码笔记:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian
- Unicode,utf-8,utf-16,utf-32,ucs16,ucs32关系
- C++字符串完全指引 && 字符编码笔记:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian (合集)
- 字符编码笔记:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian(转)
- Unicode详解(UTF-8,UTF16,UCS
- 转:对字符编码与Unicode,ISO 10646,UCS,UTF8,UTF16,GBK,GB2312的理解
- Unicode、UCS、UTF-8、UTF-16、UTF-32 的关系
- 对字符编码与Unicode,ISO 10646,UCS,UTF8,UTF16,GBK,GB2312的理解
- unicode、ucs-2、ucs-4、utf-16、utf-32、utf-8介绍
- 【转】对字符编码与Unicode,ISO 10646,UCS,UTF8,UTF16,GBK,GB2312的理解[holen@donews]