When compiling many programs, we often encounter errors such as pointer conversion errors or const char [] cannot be converted to XX. This is probably due to the project encoding problem, if you are using the vs programming environment, open the project properties. There is an option for you to choose whether to use multi-character sets or Unicode. For the two, I firmly like Unicode ~
In a multi-byte environment, the system truncates 128 characters in the ASCII two-byte table. Because Chinese characters occupy two bytes, the system instantly contains Chinese characters and English strings, this function only truncates English characters on the right of the string, but cannot process Chinese characters.
The Unicode Character Set uses two bytes to encode almost all languages in the world (0 × 0000-0 xFFFF). It can express 16 characters, that is, 65536 characters, the code segment of each language is different, and the characters expressed by two bytes are unique. Therefore, in this environment, each character has a unique encoding, so during the truncation operation, naturally, there will be no unexpected results.
I have read several well-known C ++ books, all of which refer to Unicode as the best encoding method for a project or program (but I did not mention it in some domestic books, and the source code provided is all "Multi-Byte"). Here, I didn't despise the meaning of Multi-byte. I just thought it would be best to use Unicode when writing common cross-language code.
The following section is from msdn:
To complete Unicode programming for an application, you must:
Use the _ t macro to write string code with conditions so that it can be transplanted to Unicode.
When passing a string, note that the length required by function parameters is in characters or bytes. This difference is important if Unicode strings are used.
The portable version of the string processing function when running C.
Use the following data types for character and character pointers:
Tchar: Char is used here.
Lptstr char * is used here *.
Here we will use const char *. Cstring provides operator lpctstr for conversion between cstring and lpctstr.
Cstring also provides constructors, value assignment operators, and comparison operators that recognize Unicode.
Haha ~ In addition, when _ t is used, if the system prompts you that it is an undefined identifier, it will be okay to bring atlstr. h. Haha, it's another note ~
Multi-byte and Unicode in programming