简体   繁体   English

如何在 C 中打印扩展的 ASCII 字符?

[英]How can I print extended ASCII characters in C?

How can I print for example "¶"?如何打印例如“¶”?

I need to print some ASCII extended characters but obviously printf("¶");我需要打印一些 ASCII 扩展字符,但显然printf("¶"); dosen't work.不工作。 Some other posts have taken me to this webpage but I don't know yet if there is any way to do it.其他一些帖子已将我带到此网页,但我还不知道是否有任何方法可以做到这一点。

I would appreciate some help.我会很感激一些帮助。 Thanks in advance.提前致谢。

If you are using windows, try typing chcp 65001 in cmd before you execute the program.如果您使用的是 windows,请在执行程序之前尝试在 cmd 中输入chcp 65001
This will set terminal's codepage to Unicode, allowing programs to print unicode chars.这会将终端的代码页设置为 Unicode,从而允许程序打印 unicode 字符。
For example, if your.exe file is in C:\Users\You\Desktop\test.exe :例如,如果 your.exe 文件位于C:\Users\You\Desktop\test.exe中:

> cd C:\Users\You\Desktop
> chcp 65001
> test.exe

This will also allow you to print other Unicode chars such as ⑩.这也将允许您打印其他 Unicode 字符,例如⑩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM