selectel / pyte

Simple VTXXX-compatible linux terminal emulator
http://pyte.readthedocs.org/
GNU Lesser General Public License v3.0
658 stars 102 forks source link

Handle (but ignore) ESC % <C> sequences for switching to/from UTF-8. #37

Closed dcoshea closed 9 years ago

dcoshea commented 9 years ago

This commit adds handling in the Stream class for Linux escape sequences used to select either UTF-8 or default character sets.

Currently the commands generated when these sequences are detected are ignored, but it might make sense in the future to have ByteStream use these sequences to switch encodings.

(I want to handle Linux serial console output and just want the ESC % G sequences to be ignored, I'm already taking care of decoding myself. Please note the "FIXME" in the comment where I'm not sure what to say.)

superbobry commented 9 years ago

Can you give an example of the app which uses these codes to switch encoding?

jquast commented 9 years ago

On Thu, Jul 23, 2015 at 05:12:01AM -0700, Sergei Lebedev wrote:

Can you give an example of the app which uses these codes to switch encoding?

I certainly can, mine does: https://github.com/jquast/x84/blob/master/x84/default/common.py#L244-258

dcoshea commented 9 years ago

I work with a CentOS 6-based appliance that sends these codes to its IPMI Serial-Over-LAN console. ESC % G is seen a few times during CentOS startup and while the CentOS 6 Anaconda installer is starting. I think this is probably just standard CentOS 6 behavior rather than anything set up specifically for this appliance. I also see ESC % @ sequences which I think are coming from the ISOLINUX boot loader.

Here is the interesting part of the output that I get from Anaconda, in the form of Python strings:

'running install...\r\n'
'running /sbin/loader\r\n'
'\x1b%G'
'detecting hardware...\r\n'

and from CentOS startup:

'\x1b%G'
'\t\tWelcome to \x1b[0;36mCentOS\x1b[0;39m \r\r\n'
'Starting udev: '
dcoshea commented 9 years ago

Thanks for accepting pull request #38! Is there any more information you need for this one?

superbobry commented 9 years ago

Is there any more information you need for this one?

Nope, no really. Thank you for making pyte better :)

I'll merge the PR and update the comment you were uncertain about.

dcoshea commented 9 years ago

Thanks very much!