Add support for char16_t and char32_t.
Fixes #8780.