GNU bug report logs - #17196
multibyte: printf: %s counts bytes instead of characters

Previous Next

Package: coreutils;

Reported by: Jan Novak <jn <at> turbo.sk>

Date: Sat, 5 Apr 2014 23:22:01 UTC

Severity: wishlist

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jan Novak <jn <at> turbo.sk>
To: bug-coreutils <at> gnu.org
Subject: UTF-8 printf string formating  problem
Date: Sun, 06 Apr 2014 01:17:19 +0200
Hello,

printf string format counts bytes instead of chars, which leads to broken output ...
(the same problem occurs with bash built in printf)


just try this:

$ echo $LANG
us_US.UTF-8


$ printf "|%3s|\n" "a"
|  a|

$ printf "|%3s|\n" "á"     (char is a-acute)
| á|

expected output:
|  á|

Is there some easy solution ?

TIA for the answer


Best regards
Novak




This bug report was last modified 6 years and 250 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.