开发者

Showing characters in extended ASCII code (Ubuntu)

I need to print characters part of ASCII extended, namely something like:

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?

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; 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. The default terminal in Ubuntu is gnome-terminal. You will have to change the character encoding in gnome-terminal from UTF-8 to ISO-8859-2 or use another terminal. Konsole for instance.


For me, a working codepage is IBM850. Using konsole, in profile configuration, advanced tab, you can choose the codepage. I am able to display extended ascii this way (usefull for IPMI bios access).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜