stl
宏定义,使string和wstring通知支持
#ifdef _UNICODE #define tstring wstring #else #define tstring string #endif // _UNICODE #boost
boost
boost::log 只创建文件ascii文件,unicode需要转换后写入文件
wstring 转string boost::locale::conv::from_utf(wstr, “GBK”);
string转wstring boost::locale::conv::to_utf<wchar_t>(strGbk, “gbk”);
宽字符使用wchar_t,ascii使用char否则,调用一下函数还是乱码
代码语言:javascript复制boost::locale::conv::between(str, "GBK", "UTF-8"); //utf8转gbk
boost::locale::conv::between(str, "UTF-8", "GBK"); //gbk转utf8
boost::locale::conv::to_utf<wchar_t>(str, "GBK"); //gbk转unicode
boost::locale::conv::from_utf(wstr, "GBK"); //unicode转gbk
boost::locale::conv::from_utf(wstr, "UTF-8"); //unicode转utf8
boost::locale::conv::utf_to_utf<wchar_t>(str); //utf转utf
unicode
utf8和utf16是unicode的子集