Author: Zhu Jincan
Source: http://www.cnblogs.com/clever101
I used to read "window core programming" and feelMulti-byte and wide-byte are still troublesome. At least the multibytetowidechar function and widechartomultibyte function have enough parameter meanings for us to understand. Recently, I have come into contact with a good String Conversion macro of ATL: a2w and w2a.
Easy to use,A2wUsage:
# Include < Atlconv. h >
Dosomething (lpwstr Str ); // Function Declaration
Uses_conversion;
Dosomething (a2w ( " Somestring " ));
W2a usage:
# Include < Atlconv. h >
Dosomething (lpcstr Str ); // Function Declaration
Uses_conversion;
Dosomething (w2a (L " Somestring " ));
In addition, it is best to put these two macros into a single function for implementation. For specific reasons, see:
Exercise caution when using a2wAnd other character conversion macros
Here is a detailed description of the principles of these two macros.Article:VCA macro usage problem.