Subject: Starting console/terminal Unicode support

From: [email-masked] (Ludovic Courtès)
Date: Wed, 21 Feb 2018 23:21:34 +0100

Hi Danny,

Danny Milosavljevic <[email-masked]> skribis:

> On Mon, 19 Feb 2018 21:35:05 +0100
> [email-masked] (Ludovic Courtès) wrote:
>
>> > It was a bad idea to do the "\x1b%G" in the first place.  
>> 
>> Because it’s redundant with IUTF8?
>
> I meant because the Linux kernel does it already and it's better not to
> have random multi-byte racy writes onto the tty while the mingetty
> is starting up (and possibly buffering and pending half of another sequence).

That ‘unicode-start’ code run when the ‘console-font-ttyN’ service is
started, right after ‘term-ttyN’ (mingetty) is up.  You’d hope mingetty
is really up and running once ‘term-ttyN’ is up, no?

> As far as I understand it's not redundant to do both.
>
> According to src/Linux/linux-4.12-rc2/drivers/tty/vt/vt.c, the 'G' controls
> the conversion utf-8->unicode that happens before the virtual terminal
> displays a corresponding character on the screen.
>
> On the other hand, the termios iutf8 is meant for the program running in the session.

OK, I see.

> Say you have bash on vt1, then bash can check termios for the settings and find
> out whether vt1 is UTF-8-capable (also has other settings like whether the
> terminal already supports line editing etc - old-school terminals were quite
> cool; a friend of mine salvaged a real one ^^).
>
> Note that drivers/tty/vt/vt.c only copies ONE way, from the 'G' flag to the
> termios (and that seldomly).
> Makes sense since the programs shouldn't have a say in what the terminal can do :)
>
> So I'd say guix services fiddling with termios is ... weird and the 'G' slightly
> less weird.

[...]

>> This ‘unicode-start’ procedure is essentially a port of the
>> ‘unicode_start’ script from ‘kbd’.  I suppose the justification is to
>> make sure we’re using UTF-8 input regardless of what the kernel defaults
>> or command-line options are.
>
> Yeah, but it's asking for trouble.
>
> I just checked Linux 2.6.32.1, it defaults to utf8 (IUTF8 in termios, and 'G').
>
> I'd suggest to remove both.

When we’re using the defaults, I understand both are unnecessary.  In
other cases (custom kernel build with different defaults, different
kernel command-line settings, etc.), we’d just get it wrong with things
breaking down the path, no?

Also, FWIW, systemd’s vconsole-setup.c does exactly that:

  https://github.com/systemd/systemd/blob/master/src/vconsole/vconsole-setup.c#L94

And again that corresponds to the ‘unicode_start’ script.

Thoughts?

Ludo’.