Namespaces
Variants

char8_t

From cppreference.net
헤더 파일에 정의됨 <uchar.h>
typedef unsigned char char8_t ;
(C23부터)

char8_t 는 UTF-8을 위해 사용되는 부호 없는 정수 타입이며 unsigned char 와 동일한 타입입니다.

예제

#include <stdio.h>
#include <uchar.h>
int main(void)
{
    char8_t str[] = u8"zß水🍌"; // or "z\u00df\u6c34\U0001f34c"
    size_t str_sz = sizeof str; // sizeof *str == 1 by definition
    printf("%zu UTF-8 code units: [ ", str_sz);
    for (size_t n = 0; n < str_sz; ++n)
        printf("%02X ", str[n]);
    printf("]\n");
}

가능한 출력:

11 UTF-8 code units: [ 7A C3 9F E6 B0 B4 F0 9F 8D 8C 00 ]

참고문헌

  • C23 표준 (ISO/IEC 9899:2024):
  • 7.30 Unicode 유틸리티 <uchar.h> (p: 410)

참고 항목

C++ documentation for Fundamental types