UNICODE字符串互转
来源:互联网 发布:网络文凭考公务员 编辑:程序博客网 时间:2024/05/01 23:11
UNICODE字符串互转:
//-------------------------------------------------------------------------------------
//Description:
// This function maps a character string to a wide-character (Unicode) string
//
//Parameters:
// lpcszStr: [in] Pointer to the character string to be converted
// lpwszStr: [out] Pointer to a buffer that receives the translated string.
// dwSize: [in] Size of the buffer
//
//Return Values:
// TRUE: Succeed
// FALSE: Failed
//
//Example:
// MByteToWChar(szA,szW,sizeof(szW)/sizeof(szW[0]));
//---------------------------------------------------------------------------------------
BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
{
// Get the required size of the buffer that receives the Unicode
// string.
DWORD dwMinSize;
dwMinSize = MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, NULL, 0);
if(dwSize < dwMinSize)
{
return FALSE;
}
// Convert headers from ASCII to Unicode.
MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);
return TRUE;
}
//-------------------------------------------------------------------------------------
//Description:
// This function maps a wide-character string to a new character string
//
//Parameters:
// lpcwszStr: [in] Pointer to the character string to be converted
// lpszStr: [out] Pointer to a buffer that receives the translated string.
// dwSize: [in] Size of the buffer
//
//Return Values:
// TRUE: Succeed
// FALSE: Failed
//
//Example:
// MByteToWChar(szW,szA,sizeof(szA)/sizeof(szA[0]));
//---------------------------------------------------------------------------------------
BOOL WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize)
{
DWORD dwMinSize;
dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
if(dwSize < dwMinSize)
{
return FALSE;
}
WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwSize,NULL,FALSE);
return TRUE;
}
- UNICODE字符串互转
- UNICODE字符串互转
- UNICODE字符串与二进制字符串互转
- 字符串 和 Unicode字符 的互转
- 字符串Unicode和ANSI互转函数
- unicode字符串 转汉字
- c#字符串转unicode
- Java字符串转unicode
- Java 字符串转 unicode
- 十六进制Unicode编码字符串与中文字符串互转
- 字符串转十六进制,和Unicode
- Java把字符串转Unicode
- Python 中文转Unicode字符串
- [妖路-0] 汉字字符串转unicode字符串
- C++实现中英文与UNICODE十六进制字符串互转
- 中英文与UNICODE十六进制字符串的互转
- C++中ANSI、Unicode、UTF8字符串之间的互转
- Unicode字符串
- sd card
- 无聊,
- 电话
- IIS无法处理aspx网页 HTTP Error 500.21
- Window Server 2008中开启IE中Net/ActiveX组件
- UNICODE字符串互转
- Linux下的进程间通信-详解
- 憋不住了,说两句吧
- Linux下iptables常用配置
- 中华人民共和国物权法
- 解读函数 alloc channel source
- 一个诡异问题
- 诡异的android项目报错
- 【mysql】事务死锁问题