[Bug 1710981] [NEW] printf count utf-8 chars like arrow wrong

H.-Dirk Schmitt dirk at computer42.org
Tue Aug 15 21:16:24 UTC 2017


Public bug reported:

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
ProcVersionSignature: Ubuntu 4.10.0-32.36~16.04.1-generic 4.10.17
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)

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: coreutils (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug third-party-packages xenial

** Also affects: bash (Ubuntu)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/1710981

Title:
  printf count utf-8 chars like arrow wrong

Status in bash package in Ubuntu:
  New
Status in coreutils package in Ubuntu:
  New

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
  ProcVersionSignature: Ubuntu 4.10.0-32.36~16.04.1-generic 4.10.17
  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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1710981/+subscriptions



More information about the foundations-bugs mailing list