?
This document uses PHP Chinese website manual Release
在頭文件<uchar.h>中定義 | (自C11以來) | |
---|---|---|
typedef uint_least16_t char16_t; | (自C11以來) | |
在頭文件<stdint.h>中定義 | ||
typedef / *實現(xiàn)定義* / uint_least16_t; | (自C99以來) |
char16_t是用于16位寬字符的無符號整數(shù)類型,與uint_least16_t類型相同。
uint_least16_t是寬度至少為16位的最小無符號整數(shù)類型。
在任何給定的平臺上,char16_t類型的寬度可以大于16位,但是存儲在char16_t類型的對象中的實際值將總是具有16位的寬度。
#include <uchar.h>#include <stdio.h> int main(void){ char16_t wcs[] = u"z?水?"; // or "z\u00df\u6c34\U0001f34c" size_t wcs_sz = sizeof wcs / sizeof *wcs; printf("%zu UTF-16 code units: [ ", wcs_sz); for (size_t n = 0; n < wcs_sz; ++n) printf("%#x ", wcs[n]); printf("]\n");}
可能的輸出:
6 UTF-16 code units: [ 0x7a 0xdf 0x6c34 0xd83c 0xdf4c 0 ]
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.28 Unicode實用程序<uchar.h>(p:398)
7.20.1.2最小寬度整數(shù)類型(p:290)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.18.1.2最小寬度整數(shù)類型(p:256)
| char16_t的C ++文檔 |
|:----|