Spec-Zone.ru › C

char8_t

Определено в заголовочном файле <uchar.h>
typedef unsigned char char8_t;
(с C23)

char8_t — это целое беззнаковое тип, используемый для UTF-8, и совпадает с типом unsigned char.

Пример

#include <uchar.h>
#include <stdio.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:2023):
    • 7.30 Утилиты Unicode <uchar.h> (с. 410)

См. также

Документация C++ по Fundamental types

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/c/string/multibyte/char8_t

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API