James Kanze wrote:
:: Neelesh Bodas wrote:
:
::::: On my PC (running Windows) if I ask for sizeof(TCHAR) I get 1 if
::::: UNICODE defined. Same if UNICODE (and _UNICODE) not defined. I
::::: sort of assumed that under UNICODE it would be 2? I understand
::::: on UNIX it is often 4.
:
::::: How can it be 1 for both ASCII AND Unicode?
:
:::: 1. TCHAR is not a fundamental type according to the C++ standard.
:::: It might be a type defined by your compiler.
:
:::: 2. sizeof(char) == 1 by definition. For other fundamental types,
:::: what sizeof() returns is implementation defined.
:
:: True. On a very popular Windows compiler, UNICODE and _UNICODE
:: should either both be defined, or both be undefined. Otherwise
:: these confusing things happen.
:
:: On the other hand, if you are coding for any currently supported
:: versions of Windows, you can just use wchar_t as the native
:: character type, and skip all this T-stuff.
:
: wchar_t is a C++ standard type, and available with any C++
: compiler, regardless of the system. Just using wchar_t,
: however, won't automatically make Unicode work anywhere. Using
: wide characters is different from using char, no matter how you
: cut it, and you need to adapt your program accordingly.
Sure.
In this particular case, it's about using TCHAR that can be either a
char or a wchar_t in Windows headers. My point was that there is not
much use for an 8-bit char compile anymore, as all present Windows
versions use wchar_t natively anyway. So the OP might want to skip
tons of non-standard macros, and use whar_t directly, as well.
Support for Windows 9x shouldn't be in high demand for new software,
as the OSs themselves are unsupported.
Bo Persson