How do I ensure that the characters that I am using are in either UNICODE or ASCII?
e.g.
is
going to be stored in ASCII or UNICODE?Code:const char* aString = "hello";
Thanks!
Printable View
How do I ensure that the characters that I am using are in either UNICODE or ASCII?
e.g.
is
going to be stored in ASCII or UNICODE?Code:const char* aString = "hello";
Thanks!
"hello" is always an ASCII string, L"hello" is always a Unicode string. If you want a program that works in both Unicode and ASCII builds you should use something like:
Code:#ifdef UNICODE
#define _T(X) L ## X
#else
#define _T(X) X
#endif
_T("my string") // becomes L"my string" in unicode builds
Actually, "hello" is always in the implementation's native character set (Windows-1252 for VC++, ISO-8859-1 (known as Latin-1) for GCC on x86, but for example EBCDIC for some old IBM-based imlementations, which is not a superset of ASCII), while L"hello" is always in the implementation's wide character set (UTF-16 for both GCC and VC++, I think, though it might be UCS-2 or even UCS-4 for some compilers).