What is the syntax for Unicode strings in VC ++?

How to use Unicode strings in VC ++? Of course you should #define UNICODE, but what about your lines?

Should you use the macro TEXT () or _T () throughout the text, or should you just put L in front of the lines? I suggest that all programs should use unicode these days, so it would not be cleaner to use the L prefix?

opinions?

+5
source share
3 answers

It depends on what you want to achieve. If you want to make sure that your code will compile and work correctly both with Unicode and without it, use macros TEXTor _Tand call Win32 function names by default (for example CreateWindow).

If you want your program to always use the Unicode API, you should use the prefix Lin front of your lines and call wide versions of Win32 functions (for example, CreateWindowW).

In the latter case, you will get unicode behavior regardless of whether it is defined or not UNICODE. In the first case, your application will change its behavior based on the definition UNICODE.

I agree with you that non-Unicode versions are really not relevant with Win98, so I would go with the second approach.

+2

Unicode L.

TEXT() _T() , Unicode, Unicode Windows (Windows 9x). , Windows 9x.

+1

-, :

:

.

, - Windows, _T, . Linux, UTF-8. - , , . - , - . ( .)

+1

All Articles