当前位置:网站首页>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
边栏推荐
- C language brush questions ~leetcode and simple questions of niuke.com
- C语言刷题~Leetcode与牛客网简单题
- CString在多线程中的问题
- do{}while()的妙用
- Solve the problem that pushgateway data will be overwritten by multiple push
- [cloud native training camp] module VIII kubernetes life cycle management and service discovery
- Visual upper system design and development (Halcon WinForm) -2 Global variable design
- Tensorflow realizes verification code recognition (III)
- XWiki安装使用技巧
- Jvm-08-garbage collector
猜你喜欢

The state does not change after the assignment of El switch

Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"

Detailed pointer advanced 2

视觉上位系统设计开发(halcon-winform)-3.图像控件

Introduction, use and principle of synchronized
![[cloud native training camp] module VIII kubernetes life cycle management and service discovery](/img/87/92638402820b32a15383f19f6f8b91.png)
[cloud native training camp] module VIII kubernetes life cycle management and service discovery

QT use qzxing to generate QR code

Digital image processing -- popular Canny edge detection

如何使用 @NotNull等注解校验 并全局异常处理

Jvm-03-runtime data area PC, stack, local method stack
随机推荐
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
qt使用QZxing生成二维码
Kubernetes will show you from beginning to end
Kubernetes帶你從頭到尾捋一遍
视觉上位系统设计开发(halcon-winform)-2.全局变量设计
Jvm-08-garbage collector
Popular understanding of random forest
Popular understanding of decision tree ID3
[transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
Kubernetes - yaml file interpretation
Redis主从、哨兵、集群模式介绍
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
详解指针进阶2
Backtracking method to solve batch job scheduling problem
视觉上位系统设计开发(halcon-winform)-5.相机
Popular understanding of linear regression (II)
Visual upper system design and development (Halcon WinForm) -3 Image control
Tensorflow realizes verification code recognition (II)