Wide character: Difference between revisions
m Robot-assisted disambiguation (you can help!): C programming language |
No edit summary |
||
Line 11: | Line 11: | ||
:"The width of <code>wchar_t</code> is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not use <code>wchar_t</code> for storing Unicode text. The <code>wchar_t</code> type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers." |
:"The width of <code>wchar_t</code> is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not use <code>wchar_t</code> for storing Unicode text. The <code>wchar_t</code> type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers." |
||
Under [[Windows API]], <code>wchar_t</code> is 16- |
Under [[Windows API]], <code>wchar_t</code> is 16-bits wide. Windows API breaks the ANSI/ISO C standard by not making wchar_t the character type that supports all the system representable characters in a single wchar_t unit; instead, wchar_t in Windows represents a [[UTF-16]] character (or part of it). |
||
On [[Unix]]-like systems <code>wchar_t</code> is 32- |
On [[Unix]]-like systems <code>wchar_t</code> is 32-bits wide. |
||
In [[C standard library|ANSI C library header files]], <wchar.h> and <wctype.h> deal with the wide characters. |
In [[C standard library|ANSI C library header files]], <wchar.h> and <wctype.h> deal with the wide characters. |
Revision as of 18:06, 23 February 2007
Wide character is a computer programming term. It is a vague term used to represent a datatype that is richer than the traditional 8-bit characters. It is not the same thing as Unicode.
wchar_t
is a data type in ANSI/ISO C and some other programming languages that is intended to represent wide characters.
The Unicode standard 4.0 says that
- "ANSI/ISO C leaves the semantics of the wide character set to the specific implementation but requires that the characters from the portable C execution set correspond to their wide character equivalents by zero extension."
and that
- "The width of
wchar_t
is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not usewchar_t
for storing Unicode text. Thewchar_t
type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers."
Under Windows API, wchar_t
is 16-bits wide. Windows API breaks the ANSI/ISO C standard by not making wchar_t the character type that supports all the system representable characters in a single wchar_t unit; instead, wchar_t in Windows represents a UTF-16 character (or part of it).
On Unix-like systems wchar_t
is 32-bits wide.
In ANSI C library header files, <wchar.h> and <wctype.h> deal with the wide characters.