当前位置:网站首页>Mutual conversion of CString and char*
Mutual conversion of CString and char*
2022-06-25 21:13:00 【Rabbit cloud program】
CString yes windows String , Sometimes its conversion makes people gnash their teeth , quite a lot MFC All of the interfaces involved in string conversion , Even more hateful is the conversion of byte encoding , All two lead to a variety of situations , Novice may succeed in conversion today , Next time the same method fails to convert , And many MFC The interface is hard to output correct results if the string input is wrong .
Unicode Next CString Convert to char *
CString convert to char* There are many ways , Here are three common

But this is limited to wide bytes Unicode The situation of , Not in the case of narrow bytes and multi bytes , Therefore, in general, multi byte encoding conversion is also involved , This is a headache . In general ,Unicode To convert to multiple bytes, you can use the following methods

Smart you'll find , This involves copying memory , And the calculation of string length , In particular, the last character should be assigned as 0. This is the way to success . So it can be summarized as the following steps

Of course, there are faster and simpler ways , That's using T2A,W2A, These two simple functions are artifacts , Can easily help you complete
边栏推荐
- What is ARP (address resolution protocol)? (Powercert animated videos)
- 8 minutes to understand the wal mechanism of tdengine
- laf. JS - open source cloud development framework (readme.md)
- After 20 days' interview, I finally joined Ali (share the interview process)
- Literals and type conversions of basic data types
- Lantern Festival, learning at the right time! Novice training camp attacks again, learning buff continues to fill up
- [important notice] developer document update (12.13-12.19)
- Day 29/100 local SSH password free login to remote
- Unable to connect to the server remotely locally using the Jupiter notebook
- Win10 common software
猜你喜欢

The beginning of manjaro's journey

01 network basics
![[nailing scenario capability package] smart office phone](/img/ec/c2f342a54ab69d8b834a8a1c8f8a01.jpg)
[nailing scenario capability package] smart office phone

Sqlmap for interface security testing

Cvpr2019 | the latest cvpr2019 papers are the first to read!
Interviewer: why does TCP shake hands three times and break up four times? Most people can't answer!
[data recovery in North Asia] a data recovery case in which the upper virtual machine data is lost due to the hard disk failure and disconnection of raid6 disk array

Jingxi Pinpin wechat applet -signstr parameter encryption
8 minutes to understand the wal mechanism of tdengine
![[nailing scenario capability package] manage the on-the-job / off-the-job situation of employees](/img/ec/c2f342a54ab69d8b834a8a1c8f8a01.jpg)
[nailing scenario capability package] manage the on-the-job / off-the-job situation of employees
随机推荐
[machine learning] machine learning from zero to mastery -- teach you to recognize handwritten digits using KNN
Lesson 3 urllib
Lesson 1 Preparation
Is flush app regular? Is it safe or not
Lesson 4 beautifulsoup
IPtables
Installing and configuring redis under Linux
Is it legal to open an account for flush stock trading software? Is it safe?
Boomfilter learning
Mysqldumpslow out slow statements in the database
[nailing scenario capability package] exhibition admission
[data recovery in North Asia] a data recovery case in which the upper virtual machine data is lost due to the hard disk failure and disconnection of raid6 disk array
Interviewer: why does TCP shake hands three times and break up four times? Most people can't answer!
Detailed explanation of unified monitoring function of multi cloud virtual machine
[nailing scenario capability package] smart office phone
Tencent music knowledge map search practice
Decryption of APP parameters of a cross-border export e-commerce - dunhuang.com
Xshell mouse configuration
8 minutes to understand the wal mechanism of tdengine
Illustration tcp/ip - Chapter 1 and 2 Notes