libc does not handle multi-byte grouping chars

Bug #1966064 reported by Carl-Erik Kopseng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

So I first reported this as a bug to `coreutils`, which closed the issue as the underlying reason lies in libc (*). Still, for the reproduction case I will still use `printf` from coreutils, as that uses `printf()` from libc internally.

As can be seen below, the width specifier for numeric parameters does some weird calculations when the specified locale is `nb_NO.utf8`. For instance, the number formatting rules for US and NO locales both result in the same number of characters (with ' ' instead of ','), but the Norwegian version lacks two spaces in the padded output:

$ LC_NUMERIC=en_US.utf8 printf "%s%'7d%s\n" XXX 1234 XXX
XXX 1,234XXX

$ LC_NUMERIC=nb_NO.utf8 printf "%s%'7d%s\n" XXX 1234 XXX
XXX1 234XXX

According to Pádraig Brady "The particular issue is the grouping char used
in the nb_NO.utf8 locale is multi-byte. Specifically: e2 80 af. So that character counts as 3 bytes, and the printf implementation is counting bytes, not characters, or display cells.

Given the usual consideration is display width, it probably should be considering display cells, but that's an issue for libc, not coreutils."

Filing this here in the hopes that it will be pushed upstream at some point.

* see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50336 for details

ProblemType: Bug
DistroRelease: Ubuntu 21.10
Package: libc6-dev 2.34-0ubuntu3.2
ProcVersionSignature: Ubuntu 5.13.0-35.40-generic 5.13.19
Uname: Linux 5.13.0-35-generic x86_64
ApportVersion: 2.20.11-0ubuntu71
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Wed Mar 23 12:45:17 2022
InstallationDate: Installed on 2021-08-26 (208 days ago)
InstallationMedia: Ubuntu 21.04 "Hirsute Hippo" - Release amd64 (20210420)
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: glibc
UpgradeStatus: Upgraded to impish on 2022-02-08 (42 days ago)

Revision history for this message
Carl-Erik Kopseng (carlerik) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.