What is difference between TCHAR and WCHAR?

24,769

Solution 1

If you read the entire header, you will find:

#ifdef _UNICODE
typedef WCHAR TCHAR;
#else
typedef char TCHAR;
#endif

or words to that effect.

Perhaps MS has removed the narrow option of late.

Solution 2

TCHAR can be either char or WCHAR based on the platform. WCHAR is always a 16-bit Unicode character, wchar_t.

Solution 3

http://msdn.microsoft.com/en-us/library/aa383751%28VS.85%29.aspx

TCHAR:

A WCHAR if UNICODE is defined, a CHAR otherwise.

WCHAR:

A 16-bit Unicode character. For more information, see Character Sets Used By Fonts.

Share:
24,769
Mihran Hovsepyan
Author by

Mihran Hovsepyan

Software Engineer at OneMarketData

Updated on November 05, 2020

Comments

  • Mihran Hovsepyan
    Mihran Hovsepyan over 3 years

    I've opened winnt.h header file and found there this two lines:

    typedef wchar_t WCHAR;
    

    and

    typedef WCHAR TCHAR, *PTCHAR;
    

    but there was comment in one of my posts that there is some difference between them. Then what is the difference?