Thread: about char type

  1. #1
    Registered User
    Join Date
    Jun 2010
    Location
    beijing
    Posts
    23

    about char type

    i want to code with unicode , but im not sure that WCHAR and wchar_t which one is better

  2. #2
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Quote Originally Posted by WinNT.h
    typedef wchar_t WCHAR;
    Effectively, they are the same thing. One just tends to be used when specifically programming windows applications.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by ampc View Post
    i want to code with unicode , but im not sure that WCHAR and wchar_t which one is better
    In Windows your best bet is to use #define UNICODE at the top of your source files then use the TCHAR and PTCHAR types for strings.

    There are also a number of string and path functions defined that are "unicode smart"... lstrcpy() lstrcat() etc. and Path____() all work with unicode, using THCARs, as do most windows function calls.

    A TCHAR is defined as...
    Code:
    #ifdef UNICODE
     typedef wchar_t TCHAR
     typedef wchar_t* PTCHAR
    #else
     typedef char TCHAR
     typedef char* PTCHAR
    #endif

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I don't recommend using TCHAR's. It's added level of abstraction and effort that is no longer needed in new development for Windows.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending a simple email in C++?
    By Coukapecker in forum C++ Programming
    Replies: 6
    Last Post: 04-09-2010, 12:36 PM
  2. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  3. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  5. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM