1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
//窄字符转宽字符
void ConvertA2W(wchar_t* the_strw, char* the_str, int len)//注意:默认the_strw和the_str有足够长度的内存,大于len字符; { TCHAR* old_locale = _tcsdup( _tsetlocale(LC_ALL,NULL) ); setlocale(LC_ALL, ".936"); size_t nSize = len + 1; memset(the_strw, 0, sizeof(wchar_t)*len); size_t i_tem; mbstowcs_s(&i_tem, the_strw, nSize, the_str, nSize); _tsetlocale( LC_ALL, old_locale ); //还原语言区域的设置 free( old_locale ); //还原区域设定 } //宽字符转窄字符 void ConvertW2A(wchar_t* the_strw, char* the_str, int len)//注意:默认the_strw和the_str有足够长度的内存,大于len字符; { TCHAR* old_locale = _tcsdup( _tsetlocale(LC_ALL,NULL) ); setlocale(LC_ALL, ".936"); size_t nSize = len + 1; memset(the_str, 0, sizeof(char)*len); size_t i_tem; wcstombs_s(&i_tem, the_str, nSize, the_strw, nSize); _tsetlocale( LC_ALL, old_locale ); //还原语言区域的设置 free( old_locale ); //还原区域设定 } |
wchat_t与char互转
转载 C++ Code
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
《解读window核心编程》 之 char与wchat_t在WinNT.h下的定义char wchat_t
-
char 与 byte 互转
char转bytechar a='a';by
javascript shell 游戏 ViewUI -
QString与char*的相互转换
在进行
字符串 帮助文档 封装 -
string 与 char* 互转
一、string转换为char*有3中方法:...
i++ #include