unicode下类型转化
来源:互联网 发布:互普威盾阻止软件安装 编辑:程序博客网 时间:2024/05/16 06:31
1、char->string
char cKey[MAX_PATH] = {“demo" };
string str;
str=cKey;
2、int->char
char cCurrentTime[MAX_PATH] = {0};
int nYear=2017;
sprintf_s(cCurrentTime,32, "%04d年",nYear);
3、CString->char、string
CString cstr=L"demo"
>>char *cUserName=CStringToChar(cstr);
string str=cUserName;
int len = str.GetLength();
int nBytes = WideCharToMultiByte(CP_ACP, 0, str, len, NULL, 0, NULL, NULL);
char* temp = new char[nBytes + 1];
memset(temp, 0, len + 1);
WideCharToMultiByte(CP_OEMCP, 0, str, len, temp, nBytes, NULL, NULL);
temp[nBytes] = 0;
return temp;
}
string TCHAR2String(TCHAR *STR)
{
int nLen = WideCharToMultiByte(CP_ACP, 0,STR, -1, NULL, 0, NULL, NULL);
char* chRtn =new char[nLen*sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, nLen, NULL, NULL);
string str(chRtn);
return str;
}
6、char->wchar
{
DWORD dwNum=MultiByteToWideChar(CP_ACP, 0, cText, -1, NULL, 0);
wchar_t *pwText= new wchar_t[dwNum];
if (!pwText)
{
delete[]pwText;
}
MultiByteToWideChar(CP_ACP,0, cText, -1, pwText, dwNum);
}
7、string->wchar
{
size_t size= str.length();
}
string wchar2string(TCHAR *STR)
{
int iLen = WideCharToMultiByte(CP_ACP, 0,STR, -1, NULL, 0, NULL, NULL);
char* chRtn = new char[iLen * sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, iLen, NULL, NULL);
std::string str(chRtn);
return str;
}
- unicode下类型转化
- MFC Unicode类型函数转化
- Unicode类型的CString转化为char*
- UNICODE下 CSting到string的转化
- unicode下各种类型转换
- 字符串类型的Unicode码转化为中文
- unicode 下字符类型的转换
- Unicode下的一些编码类型转换
- Unicode下CString类型转换真是烦!
- VC下常用类型转换(UNICODE)
- unicode下字符类型转换记录
- CString与std::string unicode下相互转化
- VC6下将ANSI程序转化为UNICODE基本步骤
- linux和windows下 unicode、GBK、utf-8 互相转化
- Unicode 字符集下,CString 型转化成int 型
- VC中Unicode下char 转化为 LPWSTR
- VC编程unicode字符集下char数组转化为CString
- UNICODE下CString 和 const char* 的相互转化
- 9-2号应聘Rokid公司的面试
- 完整教程--idea使用git进行项目管理
- 第二周项目一 C/C++语言中函数参数函数传递的三种方式
- 僵尸进程 linux
- ssm整合redis
- unicode下类型转化
- 华为2018秋招编程题3:接啤酒
- 5G网络承载
- 【LeetCode算法练习(C语言)】Longest Substring Without Repeating Characters
- hdu2087 剪花布条(kmp基础变形)
- 参数的初始化
- PHP和Laravel时间问题
- vue完成项目后,如何打包成静态文件,并且用Node调试
- Java websocket简单使用