How to Print UTF-16 Characters in C?
Asked Answered
M

1

6

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?

Macri answered 29/11, 2011 at 18:20 Comment(3)
You can't do this portably. You need to describe your implementation: OS and compiler.Sullivan
gcc in linux. (need more specifics? e.g. kernel version?)Macri
That sounds specific enough. I don't know the answer though!Sullivan
R
4

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.

Railroader answered 29/11, 2011 at 18:32 Comment(1)
i tried to do as advised, but seem to hit issues with printing. i posted a separate question here: #8466439Macri

© 2022 - 2024 — McMap. All rights reserved.