如何打印UTF-16字符用C? [英] How to Print UTF-16 Characters in C?
本文介绍了如何打印UTF-16字符用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含UTF-16字符的文件。我读的文件中,并可以字符存储在一个uint16_t数组或字符数组(任何更好的选择?)
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?
推荐答案
我假设你要打印到标准输出
或标准错误
。一种方法是使用 libiconv的从UTF-16转换为UTF-32(也称为作为UCS-4)成宽字符串( wchar_t的
)。然后,您可以使用 wprintf
和朋友打印到标准流。
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.
这篇关于如何打印UTF-16字符用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文