- 本文转自他出,链接为:http://blog.csdn.net/js_gary/article/details/7527232,转载请说明出处!!!
- wchar_t * ANSIToUnicode( const char* str )
- {
- int textlen ;
- wchar_t * result;
- textlen = MultiByteToWideChar( CP_ACP, 0, str,-1, NULL,0 );
- result = (wchar_t *)malloc((textlen+1)*sizeof(wchar_t));
- memset(result,0,(textlen+1)*sizeof(wchar_t));
- MultiByteToWideChar(CP_ACP, 0,str,-1,(LPWSTR)result,textlen );
- return result;
- }
- char * UnicodeToANSI( const wchar_t *str )
- {
- char * result;
- int textlen;
- // wide char to multi char
- textlen = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
- result =(char *)malloc((textlen+1)*sizeof(char));
- memset( result, 0, sizeof(char) * ( textlen + 1 ) );
- WideCharToMultiByte( CP_ACP, 0, str, -1, result, textlen, NULL, NULL );
- return result;
- }
- wchar_t * UTF8ToUnicode( const char* str )
- {
- int textlen ;
- wchar_t * result;
- textlen = MultiByteToWideChar( CP_UTF8, 0, str,-1, NULL,0 );
- result = (wchar_t *)malloc((textlen+1)*sizeof(wchar_t));
- memset(result,0,(textlen+1)*sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0,str,-1,(LPWSTR)result,textlen );
- return result;
- }
- char * UnicodeToUTF8( const wchar_t *str )
- {
- char * result;
- int textlen;
- // wide char to multi char
- textlen = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
- result =(char *)malloc((textlen+1)*sizeof(char));
- memset(result, 0, sizeof(char) * ( textlen + 1 ) );
- WideCharToMultiByte( CP_UTF8, 0, str, -1, result, textlen, NULL, NULL );
- return result;
- }
UTF8, ASCII, UNICODE相互转换
精选 转载文章标签 UTF8 编码转换 ANSI UNICODE 文章分类 C/C++ 后端开发
上一篇:通过BitMap进行排序
-
C++ string互转wstring/Unicode互转ANSI/Unicode互转UTF8
std::string StringConvUtil::UnicodeToANSI(const s
C++ string UTF Unicode ANSI -
c++ string、UTF8相互转换方法
编码格式转换,亲测有效
字符串 c++ ide 头文件 #include -
unicode to utf8
绕不开的Unicode
Unicode to utf8 -
ASCII,UTF-8,Unicode字符串相互转换
转载于:https://blog.csdn.net/Don211/article/details/51769515
ide ico #include .net JAVA -
UTF8 ANSI 相互转换的函数
1 #include <winnls.h> 2 #include <malloc.ht ALength =
ide ico #include d3