当前位置:网站首页>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
边栏推荐
- redis单线程问题强制梳理门外汉扫盲
- Qt常用语句备忘
- 【可能是全中文网最全】pushgateway入门笔记
- qt使用QZxing生成二维码
- Visual upper system design and development (Halcon WinForm) -3 Image control
- leetcode_ Power of Four
- Popular understanding of linear regression (I)
- UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
- Using TCL (tool command language) to manage Tornado (for VxWorks) can start the project
- win32创建窗口及按钮(轻量级)
猜你喜欢

Redis主从、哨兵、集群模式介绍

Popular understanding of ovo and ovr

Characteristics of MySQL InnoDB storage engine -- Analysis of row lock

基础SQL教程

Halcon与Winform学习第二节

Basic SQL tutorial

Tensorflow realizes verification code recognition (I)
![[transform] [NLP] first proposed transformer. The 2017 paper](/img/33/f639ab527d5adedfdc39f8d8117c3e.png)
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team

Visual upper system design and development (Halcon WinForm) -3 Image control

Tensorflow realizes verification code recognition (III)
随机推荐
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
自定义注解
Unity功能——Unity离线文档下载及使用
从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍
Redis主从、哨兵、集群模式介绍
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
[combinatorial mathematics] binomial theorem and combinatorial identity (binomial theorem | three combinatorial identities | recursive formula 1 | recursive formula 2 | recursive formula 3 Pascal / Ya
Visual upper system design and development (Halcon WinForm) -5 camera
redis单线程问题强制梳理门外汉扫盲
Nppexec get process return code
String functions that you need to know
Chapter 04_ Logical architecture
Visual upper system design and development (Halcon WinForm) -3 Image control
Puppet automatic operation and maintenance troubleshooting cases
Finally, someone explained the financial risk management clearly
Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
SQL server installation location cannot be changed
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
运维体系的构建
秒殺系統3-商品列錶和商品詳情