C Programming/wchar.h: Difference between revisions
[unreviewed revision] | [unreviewed revision] |
No edit summary |
|||
Line 20: | Line 20: | ||
:'''WEOF''' |
:'''WEOF''' |
||
:It defines the return value of the type wint_t but the value does not correspond to any member of the extended character set. WEOF indicates the end of a character stream, the end of file(EOF) or an error case.<ref>http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.bpxbd00%2Fwcharh.htm</ref> |
:It defines the return value of the type wint_t but the value does not correspond to any member of the extended character set. WEOF indicates the end of a character stream, the end of file(EOF) or an error case.<ref>http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.bpxbd00%2Fwcharh.htm</ref> |
||
===Types=== |
|||
:'''size_t''' |
|||
:It is a size/count type, that stores the result or the returned value of the size of operator. |
|||
:'''wchar_t''' |
|||
:An object of type wchar_t can hold a wide character. It is also required for declaring or referencing wide characters and wide strings. |
|||
:'''wint_t''' |
|||
:This type is an integer type that can hold any value corresponding to the members of the extended character set. It can hold all values of the type wchar_t as well as the value of the macro WEOF. This type is unchanged by integral promotions. |
|||
===Functions=== |
===Functions=== |
Revision as of 06:20, 6 October 2011
A Wikibookian suggests that this book or chapter be merged into C string. Please discuss whether or not this merge should happen on the discussion page. |
wchar.h is a header file in the C standard library. It is a part of the extension to the C programming language standard done in 1995. It contains extended multibyte and wide character utilities. The standard header <wchar.h> is included to perform input and output operations on wide streams. It can also be used to manipulate the wide strings.[1]
Wide Characters
C is a programming language that was developed in an environment where the dominant character set was the 7-bit ASCII code. Hence since then the 8-bit byte is the most common unit of encoding. However when a software is developed for an international purpose, it has to be able to represent different characters. For example character encoding schemes to represent the Indian, Chinese, Japanese writing systems should be available. The inconvenience of handling such varied multibyte characters can be eliminated by using characters that are simply a uniform number of bytes. ANSI C provides a type that allows manipulation of variable width characters as uniform sized data objects called wide characters. The wide character set is a superset of already existing character sets, including the 7-bit ASCII.[2]
Declarations and Definitions
Macros
The standard header wchar.h contains the definitions or declarations of some constants.
- NULL
- It is a Null pointer constant. It never points to a real object.
- WCHAR_MIN
- It indicates the lower limit or the minimum value for the type wchar_t.
- WCHAR_MAX
- It indicates the upper limit or the maximum value for the type wchar_t.
- WEOF
- It defines the return value of the type wint_t but the value does not correspond to any member of the extended character set. WEOF indicates the end of a character stream, the end of file(EOF) or an error case.[3]
Types
- size_t
- It is a size/count type, that stores the result or the returned value of the size of operator.
- wchar_t
- An object of type wchar_t can hold a wide character. It is also required for declaring or referencing wide characters and wide strings.
- wint_t
- This type is an integer type that can hold any value corresponding to the members of the extended character set. It can hold all values of the type wchar_t as well as the value of the macro WEOF. This type is unchanged by integral promotions.
Functions
int wcscmp(const wchar_t *s1, const wchar_t *s2)
is the wide-character equivalent of the strcmp(3) function. It compares the wide-character string pointed to by s1 and the wide-character string pointed to by s2.
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
is the wide-character equivalent of the strncmp function. It is similar to wcscmp(), except it only compares the first n characters of s1.
int wcscasecmp(const wchar_t *s1, const wchar_t *s2)
is the wide-character equivalent of the strcasecmp(3) function. It compares the wide-character string pointed to by s1 and the wide-character string pointed to by s2, ignoring case differences.
int wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
is similar to wcscasecmp(), except it only compares the first n characters of s1.
wcschr
wcsncat
wcsstr
wcsncpy
Template:Compu-library-stub Template:Compu-prog-stub
References
- ↑ http://www.qnx.com/developers/docs/6.4.1/dinkum_en/c99/wchar.html
- ↑ http://books.google.co.in/books?id=4Mfe4sAMFUYC&pg=PT26&lpg=PT26&dq=wide+characters+as+superset&source=bl&ots=tPLP1nN4qh&sig=f2W0ys85Ms9lRdT4HBEf_yoNL2U&hl=en&ei=H3SMTpiJFpGzrAfzvOycAg&sa=X&oi=book_result&ct=result&resnum=2&sqi=2&ved=0CCIQ6AEwAQ#v=onepage&q&f=false
- ↑ http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.bpxbd00%2Fwcharh.htm