boost::locale::conv:: 字符编码转换
来源:互联网 发布:淘宝商家虚假发货 编辑:程序博客网 时间:2024/05/22 02:06
相关字符集转换函数功能摘要:std::string boost::locale::conv::between(char const * begin, char const * end, std::string const & to_encoding, std::string const & from_encoding, method_type how = default_method ) Convert a text in range [begin,end) to to_encoding from from_encodingstd::string boost::locale::conv::between(char const * text, std::string const & to_encoding, std::string const & from_encoding, method_type how = default_method ) [inline]Convert a text to to_encoding from from_encodingstd::string boost::locale::conv::between(std::string const & text, std::string const & to_encoding, std::string const & from_encoding, method_type how = default_method ) [inline]Convert a text to to_encoding from from_encodingtemplate<typename CharType >std::string boost::locale::conv::from_utf(CharType const * begin, CharType const * end, std::string const & charset, method_type how = default_method ) convert UTF text in range [begin,end) to a text encoded with charset according to policy howtemplate<typename CharType >std::string boost::locale::conv::from_utf(CharType const * begin, CharType const * end, std::locale const & loc, method_type how = default_method ) convert UTF text in range [begin,end) to a text encoded according to locale loc according to policy howNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharType >std::string boost::locale::conv::from_utf(std::basic_string< CharType > const & text, std::string const & charset, method_type how = default_method ) Convert a text from charset to UTF stringtemplate<typename CharType >std::string boost::locale::conv::from_utf(CharType const * text, std::string const & charset, method_type how = default_method ) Convert a text from UTF to charsettemplate<typename CharType >std::string boost::locale::conv::from_utf(std::basic_string< CharType > const & text, std::locale const & loc, method_type how = default_method ) Convert a text in UTF to locale encoding given by locNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharType >std::string boost::locale::conv::from_utf(CharType const * text, std::locale const & loc, method_type how = default_method ) Convert a text in UTF to locale encoding given by locNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(char const * begin, char const * end, std::string const & charset, method_type how = default_method ) convert string to UTF string from text in range [begin,end) encoded with charset according to policy howtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(char const * begin, char const * end, std::locale const & loc, method_type how = default_method ) convert string to UTF string from text in range [begin,end) encoded according to locale loc according to policy howNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(std::string const & text, std::string const & charset, method_type how = default_method ) convert a string text encoded with charset to UTF stringtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(char const * text, std::string const & charset, method_type how = default_method ) Convert a text from charset to UTF stringtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(std::string const & text, std::locale const & loc, method_type how = default_method ) Convert a text in locale encoding given by loc to UTFNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharType >std::basic_string<CharType> boost::locale::conv::to_utf(char const * text, std::locale const & loc, method_type how = default_method ) Convert a text in locale encoding given by loc to UTFNote:throws std::bad_cast if the loc does not have info facet installedtemplate<typename CharOut , typename CharIn >std::basic_string<CharOut> boost::locale::conv::utf_to_utf(CharIn const * begin, CharIn const * end, method_type how = default_method ) Convert a Unicode text in range [begin,end) to other Unicode encodingtemplate<typename CharOut , typename CharIn >std::basic_string<CharOut> boost::locale::conv::utf_to_utf(CharIn const * str, method_type how = default_method ) Convert a Unicode NUL terminated string str other Unicode encodingtemplate<typename CharOut , typename CharIn >std::basic_string<CharOut> boost::locale::conv::utf_to_utf(std::basic_string< CharIn > const & str, method_type how = 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 的字串。
string sSource = "BIG-5字符串"; wstring ws = boost::locale::conv::to_utf<wchar_t>( sSource, "BIG5" ); string ss = boost::locale::conv::to_utf<char>( sSource, "BIG5" );
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" );
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 );
阅读全文
0 0
- boost::locale::conv:: 字符编码转换
- boost字符编码转换
- boost库学习随记五 Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- Boost.Locale 之字符转换 gbk utf8 big5 string wstring等
- boost 编码转换
- Boost编码转换
- 用boost locale库进行字符集转换的问题
- 字符编码 编码转换 乱码
- 字符编码转换
- 字符编码转换
- Java字符编码转换
- 字符编码转换工具
- 字符编码转换函数
- java字符编码转换
- 字符编码转换
- 查表法字符编码转换
- 字符编码集转换
- Android反编译apk,修改资源,打包,签名全过程
- 史上最简单的SpringCloud教程 | 第四篇:断路器(Hystrix)
- CentOS7安装JDK1.8
- Baidu Api demo
- Spring Boot + Mybatis + Redis二级缓存(Java Web现代化开发)
- boost::locale::conv:: 字符编码转换
- 文档。关于XMLHttpRequest和js 的问题整理
- if __name__ == "__main__":
- 一句话搞懂JavaSE、JavaEE和JavaME之间的区别
- 【TensorFlow】变量管理tf.get_variables/tf.Variable/tf.variable_scope的应用(七)
- Vue 中使用 jQuery
- Ubuntu 安装 JDK 7 / JDK8 的两种方式
- Js基础知识学习
- 怎么配置Jupyter Notebook默认启动目录?