当前位置:网站首页>Under VC, Unicode and ANSI are converted to each other, cstringw and std:: string are converted to each other
Under VC, Unicode and ANSI are converted to each other, cstringw and std:: string are converted to each other
2022-07-03 15:26:00 【Yulong_】
Preface
as everyone knows ,CString There are two kinds of , They are using ANSI Coded CStringA And use Unicode Coded CStringW, among CStringA and std::string The transformation of is very simple , After all, they are used ANSI code , Let's not talk about it here , Only talk CStringW and std::string The transformation of .
Text
Microsoft has provided wide and narrow byte conversion API function , But it's a little troublesome , Here is Microsoft in ATL Several macros provided in , It's very easy to use . The following conversion macros are commonly used :
1、W2A and A2W
2、CW2A and CA2W
One 、W2A and A2W How to use :
#include <atlconv.h>
#include <atlstr.h>
int main(int argc, _TCHAR* argv[])
{
// Use W2A and A2W when , This macro is required
USES_CONVERSION;
CStringW strw = L"Hello World";
//Unicode turn ANSI Use W2A
std::string strstd = W2A(strw);
//ANSI turn Unicode Use A2W
strw = A2W(strstd.c_str());
return 0;
}Before using this set of macros, you need to use USES_CONVERSION macro , This set of macros was developed by Microsoft in its early days ATL3.0 Released in , Now it seems This set of macros has
边栏推荐
- 官网MapReduce实例代码详细批注
- 视觉上位系统设计开发(halcon-winform)-6.节点与宫格
- Redis single thread problem forced sorting layman literacy
- Redis主从、哨兵、集群模式介绍
- 通过进程PID获取可执行文件路径(QueryFullProcessImageName)
- Popular understanding of linear regression (II)
- 从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍
- 整形和浮点型是如何在内存中的存储
- Dataframe returns the whole row according to the value
- Kubernetes带你从头到尾捋一遍
猜你喜欢

Unity功能——Unity离线文档下载及使用

C language brush questions ~leetcode and simple questions of niuke.com

Can‘t connect to MySQL server on ‘localhost‘

视觉上位系统设计开发(halcon-winform)-1.流程节点设计

找映射关系

What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding

Digital image processing -- popular understanding of corrosion and expansion

String functions that you need to know

详解指针进阶1

Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
随机推荐
阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
[cloud native training camp] module VIII kubernetes life cycle management and service discovery
win32创建窗口及按钮(轻量级)
秒殺系統3-商品列錶和商品詳情
XWiki安装使用技巧
Jvm-02-class loading subsystem
Analysis of development mode process based on SVN branch
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
北京共有产权房出租新规实施的租赁案例
Jvm-08-garbage collector
QT use qzxing to generate QR code
运维体系的构建
Matplotlib drawing label cannot display Chinese problems
使用JMeter对WebService进行压力测试
Popular understanding of linear regression (II)
Unity功能——Unity离线文档下载及使用
Summary of concurrent full knowledge points
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
视觉上位系统设计开发(halcon-winform)-1.流程节点设计