使用 libstdc++ 在 string、u16string 和 u32string 之间进行转换
Convert between string, u16string & u32string using libstdc++
我发现了这个主题在字符串、u16string&u32string和该解决方案(看起来非常棒(只使用libc++而不使用libstdc++。目前libc++不可用-它很难编译,在Windows上也不太好用。
是否有任何方法可以使用C++11和在所有平台上都可用的libstdc++在这些表示之间进行转换?
我特别感兴趣的是将u32_string转换为字符串(utf8(,反之亦然。
C++11中有一种可移植的方法,可以通过wstring_convert类来实现这一点。
然而,它似乎还没有实现libstdc++(截至gcc 4.8(
同样适用于:
codecvt<char16_t, char, mbstate_t>.
codecvt<char32_t, char, mbstate_t>.
codecvt_utf8.
codecvt_utf16.
codecvt_utf8_utf16.
事实上,报头<codecvt>
仍然不存在于gcc分布中。
您可以使用utf8cpp(http://utfcpp.sourceforge.net/)它将这些转换器提供为易于使用的C++。
相关文章:
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- int(c) 和 c-'0' 之间的区别。C++
- 在cuda线程之间共享大量常量数据
- 在c代码之间共享数据的最佳方式
- Mix_Init和Mix_OpenAudio SDL之间的区别是什么
- C++ 使用 assign 函数的字符串与直接使用 '=' 更改值的字符串之间的区别
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- std::atomic和std::condition_variable wait,notify_*方法之间的区别
- 大小相等但成员数量不同的结构之间的性能差异
- 类与私有变量的其他类之间的线程安全性
- 如何在cpp文件之间切换窗口?在Qt中
- 线程之间的布尔停止信号
- 我是C++编程的新手,这些代码之间有什么区别,我应该使用哪一个
- 在 const 函数中通过引用和指针返回之间的区别
- 我想知道长双倍和双倍之间的区别
- 如何防止clang格式在流运算符调用之间添加换行符<<
- 在两台机器之间进行时间戳的最佳c++chrono函数是什么
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 构造函数和转换运算符之间的重载解析
- 使用 libstdc++ 在 string、u16string 和 u32string 之间进行转换