2

It seems so. I read IUTF8, but the document only said it allows you to handle input as UTF-8 when doing line-editing.

But what about output? If you use a GUI Terminal, it usually allows you to change the encoding to render bytes in the pty's output buffer, but what about kernel-implemented tty?

Does Linux always render bytes in tty's output buffer using UTF-8?

1 Answer 1

3

"Linux" as such, does not do this. Applications (including, but not limited to, terminal emulators) do that—or do not.

The Linux console terminal is a terminal emulator which may/may not interpret UTF-8. See the console_codes(4) manual page for more information. That should list the controls for switching the output character set, e.g.,

   ESC %              Start sequence selecting character set                
   ESC % @               Select default (ISO 646 / ISO 8859-1)              
   ESC % G               Select UTF-8                                       
   ESC % 8               Select UTF-8 (obsolete) 

but seeing that the final comment on the page corresponds to this change in 2006, suspect that the conversion to web format lost some text. Another site gives a more complete representation (though that site also has issues as mentioned here).

If you really want to read the manual page, your local computer likely does a better job than either...

You can turn UTF-8 mode off/on, using the sequences ending in @ or G, respectively. I use this script occasionally to do that:

#!/bin/sh
# send character-string to enable UTF-8 mode
if test ".$1" = ".off" ; then
        printf '\033%%@'
else
        printf '\033%%G'
fi

(and having commented on that before, someone reminds that there is a script to do this, which is a little older than my script).

7

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .