名前空間
変種
操作

char16_t

From cppreference.com
< c‎ | string‎ | multibyte
ヘッダー <uchar.h> で定義
typedef uint_least16_t char16_t;
(C11 以降)

char16_tは、16ビット幅の文字に使用される符号なし整数型であり、uint_least16_tと同じ型です。

目次

[編集] 注記

任意のプラットフォームにおいて、uint_least16_tの定義により、char16_t型の幅は16ビットを超えることがありますが、char16_t型のオブジェクトに格納される実際の値の幅は常に16ビットです。

[編集]

#include <stdio.h>
#include <uchar.h>
 
int main(void)
{
    const char16_t wcs[] = u"zß水🍌"; // or "z\u00df\u6c34\U0001f34c"
    const 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 ]

[編集] 参照

  • C17標準 (ISO/IEC 9899:2018)
  • 7.28 Unicode utilities <uchar.h> (p: 292)
  • 7.20.1.2 Minimum-width integer types (p: 212-213)
  • C11標準 (ISO/IEC 9899:2011)
  • 7.28 Unicode utilities <uchar.h> (p: 398)
  • 7.20.1.2 Minimum-width integer types (p: 290)
  • C99標準 (ISO/IEC 9899:1999)
  • 7.18.1.2 Minimum-width integer types (p: 256)

[編集] 関連項目

English 日本語 中文(简体) 中文(繁體)