Jump to content

Wide character: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Reckjavik (talk | contribs)
No edit summary
Line 1: Line 1:
'''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]].
'''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]].the variable of this type store 2 bytes character ode with value in the range from 0 to 65,536


<code>wchar_t</code> is a data type in ANSI/ISO [[C (programming language)|C]], ANSI/ISO [[C++]], and some other [[programming language]]s that is intended to represent wide characters.
<code>wchar_t</code> is a data type in ANSI/ISO [[C (programming language)|C]], ANSI/ISO [[C++]], and some other [[programming language]]s that is intended to represent wide characters.
Line 18: Line 18:


According to the Python documentation, [[Python_(programming_language) | Python]] sometimes uses wchar_t as the basis for it's character type Py_UNICODE. It depends on whether wchar_t is "compatible with the chosen Python Unicode build variant" on that system. <ref>http://docs.python.org/c-api/unicode.html accessed 2009 12 19</ref>
According to the Python documentation, [[Python_(programming_language) | Python]] sometimes uses wchar_t as the basis for it's character type Py_UNICODE. It depends on whether wchar_t is "compatible with the chosen Python Unicode build variant" on that system. <ref>http://docs.python.org/c-api/unicode.html accessed 2009 12 19</ref>

''' Syntax '''

wchar_t variable = 'value'; // storing a 16bit character code and value should be either in hexadecimal or single ACII character
wchar_t variable('value');



==Functions==
==Functions==

Revision as of 17:54, 25 December 2009

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.the variable of this type store 2 bytes character ode with value in the range from 0 to 65,536

wchar_t is a data type in ANSI/ISO C, 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 use wchar_t for storing Unicode text. The wchar_t type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers."

Under Win32, wchar_t is 16 bits wide and represents a UTF-16 code unit. On Unix-like systems wchar_t is commonly 32 bits wide and represents a UTF-32 code unit.

In ANSI C library header files, <wchar.h> and <wctype.h> deal with the wide characters.

Python

According to the Python documentation, Python sometimes uses wchar_t as the basis for it's character type Py_UNICODE. It depends on whether wchar_t is "compatible with the chosen Python Unicode build variant" on that system. [1]

Syntax

wchar_t variable = 'value'; // storing a 16bit character code and value should be either in hexadecimal or single ACII character wchar_t variable('value');


Functions

There are several functions in C's stdlib.h to help with wchar_t's.

The author of GNU libc advises to avoid these due to the 'state' mechanism they involve, and instead suggests the 'restartable' mbsrtowcs et al functions. [7]

Notes