当前位置:网站首页>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
边栏推荐
- Idea does not specify an output path for the module
- Use of Tex editor
- Final review points of human-computer interaction
- mysql innodb 存储引擎的特性—行锁剖析
- Custom annotation
- 视觉上位系统设计开发(halcon-winform)
- [combinatorial mathematics] binomial theorem and combinatorial identity (binomial theorem | three combinatorial identities | recursive formula 1 | recursive formula 2 | recursive formula 3 Pascal / Ya
- 【日常训练】395. 至少有 K 个重复字符的最长子串
- What is machine reading comprehension? What are the applications? Finally someone made it clear
- Construction of operation and maintenance system
猜你喜欢
What is machine reading comprehension? What are the applications? Finally someone made it clear
求字符串函数和长度不受限制的字符串函数的详解
Kubernetes will show you from beginning to end
详解指针进阶2
Tensorflow realizes verification code recognition (I)
软件逆向破解入门系列(1)—xdbg32/64的常见配置及功能窗口
Digital image processing -- popular Canny edge detection
Jvm-05-object, direct memory, string constant pool
Reentrantlock usage and source code analysis
Introduction to redis master-slave, sentinel and cluster mode
随机推荐
[daily training] 395 Longest substring with at least k repeated characters
自定义注解
PyTorch crop images differentiablly
Halcon and WinForm study section 1
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
Digital image processing -- popular understanding of corrosion and expansion
Construction of operation and maintenance system
Kubernetes 进阶训练营 Pod基础
使用JMeter对WebService进行压力测试
视觉上位系统设计开发(halcon-winform)-3.图像控件
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
Kubernetes帶你從頭到尾捋一遍
互斥对象与临界区的区别
Nppexec get process return code
Solve the problem that pushgateway data will be overwritten by multiple push
Using Tengine to solve the session problem of load balancing
[transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
[combinatorics] permutation and combination (set permutation, step-by-step processing example)