Madrugada
Madrugada

Reputation: 1289

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

Upvotes: 5

Views: 11494

Answers (3)

Cam
Cam

Reputation: 21

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

Upvotes: 0

paldepind
paldepind

Reputation: 4870

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.

Upvotes: 1

Conrad Meyer
Conrad Meyer

Reputation: 2886

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

Upvotes: 2

Related Questions