char16_t
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <uchar.h> で定義
|
||
typedef uint_least16_t char16_t; |
(C11以上) | |
| ヘッダ <stdint.h> で定義
|
||
typedef /*implementation-defined*/ uint_least16_t; |
(C99以上) | |
char16_t は16ビットワイド文字のために使用する符号なし整数型であり、 uint_least16_t と同じ型です。
uint_least16_t は少なくとも16ビット以上の幅を持つ最も小さな符号なし整数型です。
ノート
任意のプラットフォームにおいて、 char16_t 型の幅は16ビットより大きい可能性がありますが、 char16_t 型のオブジェクトに格納される実際の値は常に16ビット幅です。
例
Run this code
#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 standard (ISO/IEC 9899:2011):
- 7.28 Unicode utilities <uchar.h> (p: 398)
- 7.20.1.2 Minimum-width integer types (p: 290)
- C99 standard (ISO/IEC 9899:1999):
- 7.18.1.2 Minimum-width integer types (p: 256)
関連項目
基本型 の C++リファレンス
|