c11 improve encoding support with built-in types for utf-8 utf-16 and utf-32.
However I was completely unable to find reference on using them in Standard functions. All I found is how to use them in c++11 not in C.
So how to printf a char32_t for example?
There isn't much to say: C11 only introduced four new standard library functions for working with
char16_t
andchar32_t
, which convert them to/from multibyte strings:char16_t
:mbrtoc16()
andc16rtomb()
char32_t
:mbrtoc32()
andc32rtomb()
With respect to
printf()
, they behave likeuint_least16_t
anduint_least32_t
types, so you can use the same format specifiers for them:If you want to print the value as a character, you will need to use the conversion functions above.
Working with
char16_t
andchar32_t
character and string literals is identical in both C11 and C++11.