简体   繁体   中英

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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