C++中宽字符和窄字符的相互转换
来源:互联网 发布:机器手编程语言 编辑:程序博客网 时间:2024/05/16 13:44
可以参考:
std::wstringANSIToUniCode(conststd::string &strCmd)
{
int bytes = ::MultiByteToWideChar(CP_ACP, 0,strCmd.c_str(),strCmd.size(),NULL,0);
std::wstringwstrCmd;
wstrCmd.resize(bytes);
bytes = ::MultiByteToWideChar(CP_ACP, 0,strCmd.c_str(),strCmd.size(),const_cast<wchar_t*>(wstrCmd.c_str()),wstrCmd.size());
return wstrCmd;
}
std::stringUnicodeToANSI(conststd::wstring &wstrCmd)
{
int bytes = ::WideCharToMultiByte(CP_ACP, 0,wstrCmd.c_str(),wstrCmd.size(),NULL,0, NULL,NULL);
std::stringstrCmd;
strCmd.resize(bytes);
bytes = ::WideCharToMultiByte(CP_ACP, 0,wstrCmd.c_str(),wstrCmd.size(),const_cast<char*>(strCmd.data()),strCmd.size(),NULL, NULL);
return strCmd;
}
std::stringUnicodeToUTF8(conststd::wstring &wstrCmd)
{
int bytes = ::WideCharToMultiByte(CP_UTF8, 0,wstrCmd.c_str(),wstrCmd.size(),NULL,0, NULL,NULL);
std::stringstrCmd;
strCmd.resize(bytes);
bytes = ::WideCharToMultiByte(CP_UTF8, 0,wstrCmd.c_str(),wstrCmd.size(),const_cast<char*>(strCmd.data()),strCmd.size(),NULL, NULL);
return strCmd;
}
- C++中宽字符和窄字符的相互转换
- c语言中数字与字符之间的相互转换
- c语言中字符数组和数字的相互转换函数
- VS中常见的宽字符和窄字符转换
- c#中字符和字节相互转换
- 【C++】UTF-8字符和GB2312字符相互转换函数
- java中字符数组和字符串的相互转换
- Java中字符和byte数组之间的相互转换
- java中字符数组和字符串的相互转换
- VC++中数字和字符之间的相互转换
- Java中字符和byte数组之间的相互转换
- Java中字符和byte数组之间的相互转换
- java中字符数组和字符串的相互转换
- java中字符数组和字符串的相互转换
- 字符和数值的相互转换
- 中文和unicode字符的相互转换
- 字符串和字符数组的相互转换
- 字符串和字符数组的相互转换
- 欢迎使用CSDN-markdown编辑器
- Atitit.月度计划日程表 每月流程表 v7 raf Ver history V7 add fest list 00cateItemImpdescR0 stat BodySport
- Volatile
- A
- 矩阵相乘
- C++中宽字符和窄字符的相互转换
- 人工智能工程师
- python 虚拟环境
- 学习设计模式笔记--策略模式
- 对象存储来势汹汹,究竟谁是“幕后推手”?
- 阶乘-LintCode
- 如何发现优秀的开源项目?
- 上海科睿副总经理魏志丽:数据可视化助力法院信息化建设
- 数据猿专访竹间智能创始人简仁贤:五分之一的岗位即将被人工智能取代