Tchar 和 char 之间的转换
来源:互联网 发布:哪个软件可以合成照片 编辑:程序博客网 时间:2024/06/09 23:48
Unicode和ANSI之间的转换真麻烦
现在在搞一个传输工具,用socket的send函数可是传输的缓冲区只能是char的
搞的我所有的TCHAR都得向char转换,真麻烦,搜到了几个函数
1. MultiByteToWideChar
从名字就知道了是多字节向宽字节的转换函数
摘自msdn
Maps a character string to a wide character (Unicode UTF-16) string. The character string mapped by this function is not necessarily from a multibyte character set.
int MultiByteToWideChar( UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar );
If this parameter is -1, the function processes the entire input string, including the null terminator. Therefore, the resulting wide character string has a null terminator, and the length returned by the function includes the terminating null character.
If this parameter is set to a positive integer, the function processes exactly the specified number of bytes. If the provided size does not include a null terminator, the resulting wide character string is not null-terminated, and the returned length does not include the terminating null character.
2. WideCharToMultiByte
从名字就知道了是宽字节向多字节的转换函数
摘自msdn
Maps a wide character string to a new character string. The new character string is not necessarily from a multibyte character set.
int WideCharToMultiByte( UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
For the CP_UTF7 and CP_UTF8 settings for CodePage, this parameter must be set to a null pointer. Otherwise, the function fails with ERROR_INVALID_PARAMETER.
For the CP_UTF7 and CP_UTF8 settings for CodePage, this parameter must be set to a null pointer. Otherwise, the function fails with ERROR_INVALID_PARAMETER.
自己mark一下,免得以后难找
- Tchar 和 char 之间的转换
- char和TCHAR之间转换
- 关于vs2005 TCHAR和char之间的转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- CString、TCHAR*、char*之间的转换函数
- CString string char TCHAR 之间的转换
- TCHAR和char转换
- TCHAR和char转换
- TCHAR和CHAR间的互相转换
- 各种类型字符之间的转换(单字节char*和宽字节wchar_t*,TCHAR和string的转换)
- string 和char * char[]之间的转换
- string char *和char[] 之间的转换
- char和TCHAR的问题
- TCHAR ,UNICODE,CHAR,wchar_t 之间的关系
- 图解高端内存[zz]
- 嵌入式上UC/OS - II使用注意点------任务调度
- (转)*Socket TIME_WAIT 问题Q&A
- epoll精髓
- 关于开发Pa个人助手的由来
- Tchar 和 char 之间的转换
- pku 1503
- 宇瞻8g微笑碟量产详细教程
- 深入javascript function对象(一)
- 深入javascript function对象(二)
- 深入javascript function对象(三)
- Tomcat、Websphere和Jboss类加载机制
- 奇怪的搞定了conficker.aa
- 翻倍黑马:掌握惯性理论 踩准股票涨跌节奏