Thursday, January 31, 2008

The world of wide characters aka Unicode

Wide characters aka unicode characters are characters that occupy 16 bits per character .
In C we have a header file specifically for that .



that contains special data type for that

wchar_t

wchar_t * text = L"Hello";

is used to tell the compiler that it should use 16 bit aka wide variants of characters.

strlen for wide characters becomes wcslen .

To take care of these problems windows provides TCHAR.H

it contains many functions starting with _t , like. ..

_tprintf


by defining _UNICODE

like

#define _UNICODE

its possible to use 16 bit / 8 bit versions of functions without much verbosity .

the same _t functions then correctly map on to their 8 bit and 16 bit counter parts.

No comments: