I have searched in many sites and did not get anything. I know that char8_t is a keyword in C++ since C++20. I am trying to find out in C, are they typedef-ing unsigned char
to char8_t
in C23 (with the release of u8 character literals). Can anyone clarify me.
Support for a char8_t
type (or typedef) has not yet been added to C23. I submitted N2231 to add it back in 2018, but was not able to attend any meetings to argue for it then.
EDIT: 2021-06-06: N2653 (char8_t: A type for UTF-8 characters and strings (Revision 1)) has been submitted for C2x. Implementations of that proposal are available for gcc here and for glibc here. Patches submitted to gcc and glibc can be found here and here respectively.
EDIT: 2022-07-06: Implementations of the library portions of N2653 have finally landed in glibc for the 2.36 release expected in August.
EDIT: 2022-12-30: N2653 (char8_t: A type for UTF-8 characters and strings (Revision 1)) was accepted for C23 during the January/February 2022 WG14 virtual meeting and wording is present as indicated in the N3054 C working draft. Compiler support is present in the in-development branch of gcc that will be released as gcc 13 in April or May. Compiler support is also present in the in-development branch of Clang that will be released as Clang 16 in March or April.
N2653 doesn't just propose the char8_t
typedef. It also proposes that the type of u8
string literals be changed to char8_t
/unsigned char
to match u8
character constants, that the mbrtoc8()
and c8rtomb()
functions from C++20 be added, and that some atomic related macros and types be added.