In the environment of vc6.0, the characters are usually encoded in ANSI mode.ProgramOr the interaction between applications requires UNICODE character encoding. For example, you can use GDI + or sqlite3 links. In VC, which methods can be used to convert characters to Unicode conveniently.
1. Use the uses_conversion method in ATL and then use the a2w or T2W Method for conversion. This conversion method is mainly applied for memory in the stack, so it is not a safe method, it is prone to overflow.
2. directly use the multibytetowidechar method to convert a string to a Unicode character. before conversion, there is a method that is set to null at the position of the string pointer to be converted for the first time. At this time, the returned value is the length of the string to be converted, and then the memory is applied for conversion. This method requires a lot of manual writing.CodeAnd manually released.
3. The application uses the combstr class in ATL. First, it applies for an empty class object and then uses the append method to embed its own string into the string class. At this time, after using (BSTR) for forced conversion, you can obtain the Unicode string. This method avoids manual memory application and memory release. Relatively convenient. Of course, the _ bstr_t class is similar.
4. If the cstring method is used and the code is compiled in non-ANSI mode, you can use the sysallocstring method of cstring to obtain the Unicode string in cstring. However, this method requires manual release of memory units, call sysfreestring.