프로그래밍

[TIP] Wide Characters, UNICODE on Windows

봄바다별하늘 2006. 2. 1. 00:52

 

Wider Characters

typedef unsigned short wchar_t ;
wchar_t c = `A' ;
wchar_t * p = L"Hello!" ;
static wchar_t a[] = L"Hello!" ;
wchar_t c = L'A' ;

Wide-Character Library Functions

wchar_t * pw = L"Hello!" ;
size_t __cdecl wcslen (const wchar_t *) ;
iLength = wcslen (pw) ;

 

If an identifier named _UNICODE is defined and the TCHAR.H header file is included in your program, _tcslen is defined to be wcslen:

  #define _tcslen wcslen

  typedef wchar_t TCHAR ;

  #define __T(x) L##x

  #define __T(x) x

If UNICODE isn't defined, _tcslen is defined to be strlen:

  #define _tcslen strlen

  typedef char TCHAR ;

  #define _T(x) __T(x)
  #define _TEXT(x) __T(x)

  _TEXT ("Hello!")

 

winnt.h

  typedef char CHAR ;
  typedef wchar_t WCHAR ;     // wc

 

Windows' String function

ILength = lstrlen (pString) ;
pString = lstrcpy (pString1, pString2) ;
pString = lstrcpyn (pString1, pString2, iCount) ;
pString = lstrcat (pString1, pString2) ;
iComp = lstrcmp (pString1, pString2) ;
iComp = lstrcmpi (pString1, pString2) ;

 

ASCII Wide-Character Generic
Variable Number
of Arguments
Standard Version sprintf swprintf _stprintf
Max-Length Version _snprintf _snwprintf _sntprintf
Windows Version wsprintfA wsprintfW wsprintf
Pointer to Array
of Arguments
Standard Version vsprintf vswprintf _vstprintf
Max-Length Version _vsnprintf _vsnwprintf _vsntprintf
Windows Version wvsprintfA wvsprintfW wvsprintf


 

from Programming Windows, Fifth Edition (Charles Petzold)