简体   繁体   English

以扩展ASCII码显示字符(Ubuntu)

[英]Showing characters in extended ASCII code (Ubuntu)

I need to print characters part of ASCII extended, namely something like: 我需要打印ASCII扩展的字符部分,即:

char p = 219; // a rectangle   
printf("%c\n", p);

However, in the shell it does not show the proper character .. what can i do to see the rectangle? 但是,在shell中它没有显示正确的字符..我该怎么做才能看到矩形?

Thank you 谢谢

Use libiconv to convert the CP-1252 or ISO-8859-1 or whatever 8-bit character set you are converting from to UTF-8; 使用libiconv将CP-1252或ISO-8859-1或您要转换的任何8位字符集转换为UTF-8; something like this: 这样的事情:

#include <iconv.h>
iconv_t cd = iconv_open("utf-8", "cp-1252");
iconv(cd, &inbuf, sizeof(inbuf), &outbuf, sizeof(outbuf)); // <- psuedocode, change to meet your needs

You will have to use a virtual terminal that supports extended ASCII. 您必须使用支持扩展ASCII的虚拟终端。 The default terminal in Ubuntu is gnome-terminal. Ubuntu中的默认终端是gnome-terminal。 You will have to change the character encoding in gnome-terminal from UTF-8 to ISO-8859-2 or use another terminal. 您必须将gnome-terminal中的字符编码从UTF-8更改为ISO-8859-2或使用其他终端。 Konsole for instance. 例如Konsole

For me, a working codepage is IBM850 . 对我来说,一个工作代码页是IBM850 Using konsole , in profile configuration, advanced tab, you can choose the codepage. 使用konsole ,在配置文件配置,高级选项卡中,您可以选择代码页。 I am able to display extended ascii this way (usefull for IPMI bios access). 我能够以这种方式显示扩展的ascii(对于IPMI bios访问很有用)。

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

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