[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to output Unicode?



Simplified problem statement: make a program that outputs the MS-DOS
ASCII table to the console (0x32 - 0x255, without control characters).
I mean the one containing the pseudo-graphic characters - simply
writing chars 128-255 gives me 32 block characters, some math/currency
symbols and then international chars.

Possible solution: use UTF-8?

I searched the web, but all I found is this perl script:

---------------------------------------------------------
#!/usr/bin/perl -w

print "\e\%G";   # select utf-8 mode

for (0x00..0xFF) {
    printf "%02X: ", $_;
    print chr(0xEF),
          chr(0x80 | ($_ >> 6)),
          chr(0x80 | ($_ & 0x3F));
    print $_ % 8 == 7 ? "\n" : "   ";
}

print "\e\%@";   # select iso mode
---------------------------------------------------------

However, it works only when I run it from the TTYs. On Konsole, xterm,
gnome-terminal, it displays block characters. Also, if I use ANSI
sequences (to move the caret, change the text color etc.), weird
glitches appear (even if I turn
utf-8 mode on only to display one character at a time).

So: how is it done correctly?



Reply to: