Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Print UTF-16 Characters in C?

Tags:

c

utf-16

i have a file containing UTF-16 characters. i read in the file and can store the characters either in a uint16_t array or a char array (any better choice?)

But how do i print those characters?

like image 628
Edwin Lee Avatar asked Oct 10 '22 08:10

Edwin Lee


1 Answers

I'm assuming you want to print to stdout or stderr. One method would be to use libiconv to convert from UTF-16 to UTF-32 (also known as UCS-4) into a wide-character string (wchar_t). You could then use wprintf and friends to print to the standard streams.

like image 176
Mike Steinert Avatar answered Oct 12 '22 09:10

Mike Steinert