When I created my visual studio project it defaulted to forcing me to use wide strings for all the functions which take character strings. MessageBox() for example, takes a LPCWSTR rather than a const char*. While I understand that it's great for multi-lingual and portable applications, it is completely unnecessary for my simple little app. Quite frankly, it's more of a pain to constantly type TEXT() around all my strings.
Is there a compiler option, define or project setting which I can alter to fix this in my Visual Studio project?
The wchar_t type is an implementation-defined wide character type. In the Microsoft compiler, it represents a 16-bit wide character used to store Unicode encoded as UTF-16LE, the native character type on Windows operating systems.
For Unicode platforms, TCHAR is defined as synonymous with the WCHAR type. MAPI clients can use the TCHAR data type to represent a string of either the WCHAR or char type. Be sure to define the symbolic constant UNICODE and limit the platform when it is required.
This function is used to convert the numerical value to the wide string i.e. it parses a numerical value of datatypes (int, long long, float, double ) to a wide string. It returns a wide string of data type wstring representing the numerical value passed in the function.
Right click on your project -> Properties then go to the following tree item:
Configuration Properties -> General
For Unicode select:
Use Unicode Character Strings
For normal multi-byte select:
Use Multi-Byte Character Set
When you put TEXT()
or _T()
around your strings, you are making it compatible with both of the character string options. If you select Use multi-byte character set
then you do not need anything around your strings. If you select Use unicode character set
, you need at least L in front of your strings.
By selecting Use Unicode Character Strings
you are also by default using all of the Win32 API that end in W. Example: MessageBox
maps to MessageBoxW
.
When you select Use multi-byte character set
you are also by default using all of the Win32 API that end in A. Example: MessageBox
maps to MessageBoxA
.
It is worth noting that you can explicitly declare wide character string literals of the form:
WCHAR *s = L"Hello Wide World.";
which requires fewer keystrokes than the macros TEXT() or _T(), but which will make a wide character string even if UNICODE is not defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With