質問

C99 and C11 support wchar_t and multibyte functions .But I am not sure about ANSI C (1989).

Is it correct that wchar_t and multibyte functions (mblen, mbstowcs, mbtowc, wcstombs, wctomb) are part of ANSI C?

I don't find these functions in Kernighan and Ritchie book (C Programming Language (2nd Edition)).

http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628

役に立ちましたか?

解決

The name wchar_t is in the C89 (and C99) standard(s), but it is not a langauge-supported type. It is a typedef for some integer type capable of holding the requisite number of bits. C89 7.1.6 [Standard Definitions ] says:

wchar_t
which is an integral 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 and each member of the basic character set defined in 5.2.1 shall have a code value equal to its value when used as the lone character in an integer character constant.

This means that someone can define wchar_t to be whatever they want in C89 so long as <stddef.h> has not been #included.

In C++, this is illegal; wchar_t is a keyword in that language.


As for the multibyte functions you referenced, they appear to be part of C89. Section 7.10.7 [Multibyte character functions] defines mblen, mbtowc, wctomb, and 7.10.8 [Multibyte string functions] defines mbstowcs, and wcstombs (all in <stdlib.h>). Note of course that because C89 does not have const that the const-qualified versions of these functions are not available.

他のヒント

wchar_t is part of ANSI C (1989).

wchar_t is perfectly C89 standard. In my edition, wchar_t is mentioned at section § A2.5.2 in Kernighan and Ritchie book.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top