printf UTF8 字符与 printf 来自十六进制整数

发布于 2024-10-08 11:16:04 字数 252 浏览 0 评论 0原文

有点微不足道的事情,但是... 十六进制纯 C 打印日语字符

我想使用来自 此表,我知道,表中的第一个字符,あ的实体是&#12353,其十六进制实体是x3041等。

但是我如何使用这两个数字来打印命令行中的所有字符?

Kind of trivial thing but ...
I want to print japanese characters using plain C from Hexadecimals

From this table, I know that, the first char in the table, あ's Entity is &# 12353 and its Hex Entity is x3041, etc.

But how do I use this two numbers in order to get printed all characters in the command line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

圈圈圆圆圈圈 2024-10-15 11:16:04

如果你的终端设置为UTF-8并且语言环境设置正确,你可以这样写:

char s[]="あ";

你也可以尝试

 char s[]={0xe3,0x81,0x82,0x0}

(最后是“あ”的Unicode UTF-8编码),然后只需 printf("%s “,s);

If your terminal is set to UTF-8 and locale is set correctly, you may write:

char s[]="あ";

you can also try

 char s[]={0xe3,0x81,0x82,0x0}

(the last is the Unicode UTF-8 encoding for "あ"), and then just printf("%s",s);

萧瑟寒风 2024-10-15 11:16:04

如果定义了 __STDC_ISO_10646__,则 wchar_t 采用 Unicode,您可以执行以下操作:

printf("%lc", (wchar_t)0x3041);

If __STDC_ISO_10646__ is defined, wchar_t is in Unicode, and you can do something like:

printf("%lc", (wchar_t)0x3041);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文