text: c.
  [edit] Example
  #include <stdio.h> #include <locale.h> #include <uchar.h> #include <stdlib.h> mbstate_t state; int main(void) { setlocale(LC_ALL, "en_US.utf8"); char32_t str[] = U"zß水🍌"; // or z\u00df\u6c34\U0001F34C size_t str_sz = sizeof str / sizeof *str; printf("Processing %zu UCS-4 code units: [ ", str_sz); for(size_t n = 0; n < str_sz; ++n) printf("%#x ", str[n]); puts("]"); char out[MB_CUR_MAX]; for(size_t n = 0; n < str_sz; ++n) { int rc = c32rtomb(out, str[n], &state); printf("%#x converted to [ ", str[n]); for(int x = 0; x < rc; ++x) printf("%#x ", (unsigned char)out[x]); puts("]"); } }
  Output:
  Processing 5 UCS-4 code units: [ 0x7a 0xdf 0x6c34 0x1f34c 0 ] 0x7a converted to [ 0x7a ] 0xdf converted to [ 0xc3 0x9f ] 0x6c34 converted to [ 0xe6 0xb0 0xb4 ] 0x1f34c converted to [ 0xf0 0x9f 0x8d 0x8c ] 0 converted to [ 0 ]
  [edit] References
  - C11 standard (ISO/IEC 9899:2011):
  - 7.28.1.4 The c32rtomb function (p: 401)