当前位置:网站首页>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
边栏推荐
- win32创建窗口及按钮(轻量级)
- Detailed pointer advanced 1
- 《微服务设计》读书笔记(上)
- qt使用QZxing生成二维码
- Visual upper system design and development (Halcon WinForm) -4 Communication management
- 需要知道的字符串函数
- 秒杀系统1-登录功能
- [combinatorics] combinatorial identities (recursive combinatorial identities | sum of variable terms | simple combinatorial identities and | sum of variable terms | staggered sums of combinatorial ide
- Enable multi-threaded download of chrome and edge browsers
- The markdown file obtains the pictures of the network and stores them locally and modifies the URL
猜你喜欢

秒杀系统3-商品列表和商品详情

Chapter 04_ Logical architecture

VS2017通过IP调试驱动(双机调试)
![[probably the most complete in Chinese] pushgateway entry notes](/img/5a/6dcb75f5d713ff513ad6842ff53cc3.png)
[probably the most complete in Chinese] pushgateway entry notes

Halcon and WinForm study section 2

Construction of operation and maintenance system

qt使用QZxing生成二维码

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

Kubernetes带你从头到尾捋一遍

运维体系的构建
随机推荐
Detailed pointer advanced 2
Digital image processing -- popular understanding of corrosion and expansion
win32创建窗口及按钮(轻量级)
PyTorch crop images differentiablly
互斥对象与临界区的区别
Chapter 04_ Logical architecture
What is machine reading comprehension? What are the applications? Finally someone made it clear
软件安装信息、系统服务在注册表中的位置
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
Detailed comments on MapReduce instance code on the official website
[combinatorial mathematics] binomial theorem and combinatorial identity (binomial theorem | three combinatorial identities | recursive formula 1 | recursive formula 2 | recursive formula 3 Pascal / Ya
Summary of concurrent full knowledge points
GCC cannot find the library file after specifying the link library path
Nppexec get process return code
如何使用 @NotNull等注解校验 并全局异常处理
Puppet自动化运维排错案例
Solve the problem that pushgateway data will be overwritten by multiple push
Using TCL (tool command language) to manage Tornado (for VxWorks) can start the project
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team