Bug 90025

Summary: systemctl: unaligned display in UTF-8 locales
Product: systemd Reporter: Tomasz Torcz <zdzichu>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: piotrdrag
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Tomasz Torcz 2015-04-14 06:44:27 UTC
I've noticed that systemctl output is not column-aligned in some cases. I'm using pl_PL.utf-8 locale:

$ systemctl list-timers
NEXT                           LEFT       LAST                          PASSED    UNIT                         ACTIVATES
wto 2015-04-14 08:50:09 CEST   14min left wto 2015-04-14 07:50:09 CEST  45min ago dnf-makecache.timer          dnf-makecache.service
śro 2015-04-15 00:00:00 CEST  15h left   wto 2015-04-14 00:00:37 CEST  8h ago    yum-cron-security.timer      yum-cron-security.service
śro 2015-04-15 08:24:49 CEST  23h left   wto 2015-04-14 08:24:49 CEST  10min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

If you use monospace font and wide terminal, you will notice that two last lines are not aligned. "15h left" and "23h left" are moved single character to the left. Misalignment is carried on the rest of the columns to the right.
I *think* the cause is the letter "ś" in first character of the line. Probably multibyte utf-8 character isn't accounted properly.


This issue is not visible in non-utf8 locale:

$ LC_ALL=C systemctl list-timers
NEXT                          LEFT       LAST                          PASSED    UNIT                         ACTIVATES
Tue 2015-04-14 08:50:09 CEST  14min left Tue 2015-04-14 07:50:09 CEST  45min ago dnf-makecache.timer          dnf-makecache.service
Wed 2015-04-15 00:00:00 CEST  15h left   Tue 2015-04-14 00:00:37 CEST  8h ago    yum-cron-security.timer      yum-cron-security.service
Wed 2015-04-15 08:24:49 CEST  23h left   Tue 2015-04-14 08:24:49 CEST  10min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service


$ systemctl --version; rpm -q systemd
systemd 219
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN

systemd-219-11.fc22.x86_64
Comment 1 Zbigniew Jedrzejewski-Szmek 2015-04-14 12:30:29 UTC
Yes, we generally use strlen(), and any multi-byte unicode character is going to mess this up. We *could* count unicode units without too much trouble, but to really support this, we might have to understand combining characters.
Comment 2 Zbigniew Jedrzejewski-Szmek 2015-04-14 12:46:46 UTC
...though just counting code points is easy and would give us reasonable support for some languages (those which don't use separate combining characters by default, e.g. Polish). So I think we should do that for now.
Comment 3 Lennart Poettering 2017-10-27 18:08:16 UTC
Current versions of systemd have the necessary bits in place to count wide unicode characters correctly. Closing.

(Should I be mistaken and this is still an issue, please file a bug on the github issue tracker instead)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.