Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
来源:互联网 发布:中国植物图谱数据库 编辑:程序博客网 时间:2024/05/10 06:43
Boost.Locale是一个库,它提供高质量的本地化的设施在C + +的方式。它最初是设计的一部分CppCMS - C + +的Web框架的项目,然后促成了提升。
Boost.Locale提供强大的工具,跨平台的本地化软件开发 - 这会谈到用户在其语言的软件。
提供的功能:
- 正确的大小写转换,大小写和规范化。
- 整理(排序),其中包括4 Unicode排序规则层面的支持。
- 日期,时间,时区和日历操作,格式化和分析,包括对日历比公历其他透明的支持。
- 边界分析字,词,句和换行符。
- 数字格式,拼写和语法分析。
- 货币格式和解析。
- 强大的邮件格式(字符串翻译),包括多种格式,使用GNU目录的支持。
- 字符集转换。
- 8位字符透明支持集,如拉丁文
- 支持
的char
和wchar_t的
- 对C + +0 x的实验性支持
char16_t
和char32_t
字符串和数据流。
Boost.Locale提高和统一了标准库的API,它变得非常有用和方便开发跨平台的和“跨文化”软件的方式。
相关字符集转换函数功能摘要:
default_method
) Convert a text in range [begin,end) to to_encoding from from_encoding
default_method
) [inline]
Convert a text to to_encoding from from_encoding
default_method
) [inline]
Convert a text to to_encoding from from_encoding
default_method
) convert UTF text in range [begin,end) to a text encoded with charset according to policy how
default_method
) convert UTF text in range [begin,end) to a text encoded according to locale loc according to policy how
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) Convert a text from charset to UTF string
default_method
) Convert a text from UTF to charset
default_method
) Convert a text in UTF to locale encoding given by loc
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) Convert a text in UTF to locale encoding given by loc
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) convert string to UTF string from text in range [begin,end) encoded with charset according to policy how
default_method
) convert string to UTF string from text in range [begin,end) encoded according to locale loc according to policy how
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) convert a string text encoded with charset to UTF string
default_method
) Convert a text from charset to UTF string
default_method
) Convert a text in locale encoding given by loc to UTF
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) Convert a text in locale encoding given by loc to UTF
- Note:
- throws std::bad_cast if the loc does not have info facet installed
default_method
) Convert a Unicode text in range [begin,end) to other Unicode encoding
default_method
) Convert a Unicode NUL terminated string str other Unicode encoding
default_method
) Convert a Unicode string str other Unicode encoding
简单示例:
1、between把 source 这个字串从BIG5 转换到 UTF-8:
- string source = "BIG5字符串";
- string s = boost::locale::conv::between( source, "UTF-8", "BIG5" );
2、to_utf可以输出 string ,也可以输出成 wstring。像下面的例子,就是把 sSource 这个 BIG-5 编码的字串,依序转换成 wstring 和 string 的字串。
3、from_utf 是把 UTF 字串(string 或wstring)、转换为特定编码的字串用的,他可以转换string或wstring 的字串,但是输出一定是string。
下面的例子,就是把 sSource 和 wSource 这两个 UTF 字串,都转换成 BIG-5 的 string 字串。
- string sSource = "字符串";
- wstring wSource = L"...";
- string ss1 = boost::locale::conv::from_utf( wSource, "BIG5" );
- string ss2 = boost::locale::conv::from_utf( sSource, "BIG5" );
4、utf_to_utf的目的,是在 UTF 的 string 字串和 wstring 字串之间做转换,下面的例子,就是把类型是string 的 sSource 转换成 wstring、并把类型是 wstring 的 wSource 转换成 string
- string sSource = "...";
- wstring wSource = L"...";
- wstring wStr = boost::locale::conv::utf_to_utf<wchar_t>( sSource );
- string sStr = boost::locale::conv::utf_to_utf<char>( wSource );
- boost库学习随记五 Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- 字符集编码(GBK,BIG5,UNICODE等)与C++的string/wstring
- 字符集编码(GBK,BIG5,UNICODE等)与C++的string/wstring .
- 常用字符转换 string wstring utf8 unicode ascii
- 字符集编码(GBK,BIG5,UNICODE)与C++的string/wstring
- 字符集编码(GBK,BIG5,UNICODE)与C++的string/wstring
- string, wstring 转换, _wtol等
- 【语言国际化】字符集编码(GBK,BIG5,UNICODE)与C++的string/wstring
- boost::locale::conv:: 字符编码转换
- 字符格式(gbk utf8等)
- utf8字符编码格式转换gbk
- utf8与gbk字符编码的转换
- UTF8与GBK字符编码转换
- 利用boost做string到wstring转换,以及字符集转换
- ASCII,unicode, utf8 ,big5 ,gb2312,gbk,gb18030等几种常用编码区别
- ASCII,unicode, utf8 ,big5 ,gb2312,gbk,gb18030等几种常用编码区别
- 如何去除Eclipse下的JS引入报错(类似Syntax error on token "undefined", invalid FormalParameter 的异常信息)
- 毕业生们,请听听科技界大佬们的忠告
- DSP中CMD文件
- Eclipse中用Tomcat发布的Web项目,更改其部署路径
- Android在搭建时关于annotations.jar 不存在报错
- Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- 2014.7.7模拟赛【无线通讯网】
- 访问者模式的c++代码实现
- sizeof和strlen的一些事
- HTML5 Notifications 桌面提醒
- ubuntu root 密码
- linux权限
- 总结一处笔误
- Windows批处理命令教程