多字节和宽字符Multibyte and Wide Characters

多字节字符是由一个或多个字节的序列构成的字符。A multibyte character is a character composed of sequences of one or more bytes. 每个字节序列表示扩展字符集中的单个字符。Each byte sequence represents a single character in the extended character set. 多字节字符用于字符集(如日文汉字)中。Multibyte characters are used in character sets such as Kanji.

宽字符是宽度始终为 16 位的多语言字符代码。Wide characters are multilingual character codes that are always 16 bits wide. 字符常量的类型是 char;对于宽字符,该类型是 wchar_tThe type for character constants is char; for wide characters, the type is wchar_t. 由于宽字符始终具有固定大小,因此使用宽字符集可以简化使用国际字符集进行的编程。Since wide characters are always a fixed size, using wide characters simplifies programming with international character sets.

宽字符串文本 L"hello" 将成为类型为 wchar_t 的六个整数的数组。The wide-character-string literal L"hello" becomes an array of six integers of type wchar_t.

{L'h', L'e', L'l', L'l', L'o', 0}  

Unicode 规范是宽字符的规范。The Unicode specification is the specification for wide characters. 用于多字节和宽字符之间的转换的运行库例程包括 mbstowcsmbtowcwcstombswctombThe run-time library routines for translating between multibyte and wide characters include mbstowcs, mbtowc, wcstombs, and wctomb.

请参阅See Also

C 标识符C Identifiers