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

Bug#1029069: libc6: wcswidth doesn't report correct width for :



Package: libc6
Version: 2.36-6
Severity: minor

I've been trying to work out why the Chinese translation for free
doesn't want to line up the columns like everyone else, report is
at [1]

For some reason, it thinks the strange colon used in the translation is
one character wide, but its actually two. This means the column is
mis-aligned.

A small test program:
------
#define _XOPEN_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

void printme(char *str)
{
    int len, width;
    wchar_t wstr[BUFSIZ];

    len = mbstowcs(wstr, str, BUFSIZ);
    width = wcswidth(wstr, 99);
    printf("len=%d width=%d\n",
            len, width, str);
    printf("%s%.s%s\n", str, 6 - width, "blah");
}

int main()
{
    printme(":");
    printme(":");

}
------
$~/width
len=1 width=1
:blah
len=-1 width=1
:blah

We can see that the second colon is 2 wide, the "b" in blah lines up
with the "n" in len but wcswidth thinks it is 2.  I have no idea why
this is so and even where this information comes from.

It's not the end-of-the world sort of bug, but it is a very stange one.

 - Craig

1: https://gitlab.com/procps-ng/procps/-/issues/213


-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.0.0-6-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libc6 depends on:
ii  libgcc-s1  12.2.0-10

Versions of packages libc6 recommends:
ii  libidn2-0  2.3.3-1+b1

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.80
pn  glibc-doc              <none>
ii  libc-l10n              2.36-6
pn  libnss-nis             <none>
pn  libnss-nisplus         <none>
ii  locales                2.36-6

-- debconf information excluded

Reply to: