printf count utf-8 chars like arrow wrong
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Debian) |
New
|
Unknown
|
|||
bash (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
coreutils (Debian) |
New
|
Unknown
|
|||
coreutils (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
The printf command in bash (builtin) and corutils /usb/bin/printf have an error in counting the length of a string, if a non-ascii character is involved.
Example is the arrow - type Alt+I.
Try the following commands:
printf -v r "%-2s X\n" '→' ; echo ${#r} # prints 4
printf -v r "%-2s X\n" ' ' ; echo ${#r} # prints 5
The coreutils version of printf has the same misbehaviour.
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: coreutils 8.25-2ubuntu3~16.04
ProcVersionSign
Uname: Linux 4.10.0-32-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.10
Architecture: amd64
CurrentDesktop: GNOME
Date: Tue Aug 15 23:05:40 2017
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)
Changed in bash (Debian): | |
status: | Unknown → New |
Changed in coreutils (Debian): | |
status: | Unknown → New |
The bug leads to ugly output on the console if the data contains such characters.
See the 3rd song in the following play queue listing:
------- ------- ------- ------- ------- ------- ------- ------- ------- ----- ------- ------- ------- ------- ------- ------- ------- ------- ----- ------- ------- ------- ------- ------- ------- ------- ------- -----
Pos. Artist Title Dur.
-------
1. Bryan Adams I'm Ready 4:26
2. Toto Mrs. Johnson 3:48
3. The Doobie Brothers Long Train Runnin’ 3:39
4. Three Dog Night One 3:02
5. Norman Greenbaum Spirit in the Sky 3:51
-------