I know it is not a built in data type. In c++ i understand we can create a data type which looks and acts almost similar to basic data type. But in C I don't understand how it works similar to basic data type.

有帮助吗?

解决方案

I know it is not a standard data type

Yes, its standard (described in <stddef.h>)

wchar_t Integral type whose range of values can represent distinct wide-character codes for all members of the largest character set specified among the locales supported by the compilation environment: the null character has the code value 0 and each member of the Portable Character Set has a code value equal to its value when used as the lone character in an integer character constant.

But in C I don't understand how it works similar to basic data type.

Use the functions and macros of wchar.h header

其他提示

In C, wchar_t is a typedef for an integer type defined in <stddef.h> (and possibly other headers).

See the Standard, section 7.17 ( http://port70.net/~nsz/c/c99/n1256.html#7.17 )

wchar_t is an integer type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales; the null character shall have the code value zero.

Both the C++11 and the C11 standards recognize wchar_t as a "wide character" standard data type.

The C11 standard defines the semantics of wchar_t in 7.19/2:

The types are [...] and
wchar_t
which is an integer type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales; the null character shall have the code value zero. Each member of the basic character set shall have a code value equal to its value when used as the lone character in an integer character constant if an implementation does not define __STDC_MB_MIGHT_NEQ_WC__.

While the C++11 standard says in 3.9.1/5:

Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largest extended character set specified among the supported locales (22.3.1). Type wchar_t shall have the same size, signedness, and alignment requirements (3.11) as one of the other integral types, called its underlying type. [...]

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top