[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17196: UTF-8 printf string formating problem
From: |
Pádraig Brady |
Subject: |
bug#17196: UTF-8 printf string formating problem |
Date: |
Sun, 06 Apr 2014 19:13:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 04/06/2014 11:15 AM, Pádraig Brady wrote:
> On 04/06/2014 12:17 AM, Jan Novak wrote:
>> 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
>
> Yes printf follows the C standard which only considers bytes.
> awk does respect characters in width specifiers though:
>
> $ awk 'BEGIN{printf "|%3s|\n", "á"}'
> | á|
Jan points out to me the the awk solution is not portable
to mawk 1.3.3 at least. I used GNU Awk 3.1.8 above.
Pádraig.
- bug#17196: UTF-8 printf string formating problem, Jan Novak, 2014/04/06
- bug#17196: UTF-8 printf string formating problem, Pádraig Brady, 2014/04/06
- bug#17196: UTF-8 printf string formating problem,
Pádraig Brady <=
- bug#17196: UTF-8 printf string formating problem, Bob Proulx, 2014/04/06
- bug#17196: UTF-8 printf string formating problem, Pádraig Brady, 2014/04/07
- bug#17196: UTF-8 printf string formating problem, Jan Novak, 2014/04/07
- bug#17196: UTF-8 printf string formating problem, Eric Blake, 2014/04/07
- bug#17196: UTF-8 printf string formating problem, Pádraig Brady, 2014/04/07
- bug#17196: UTF-8 printf string formating problem, Eric Blake, 2014/04/07
- bug#17196: UTF-8 printf string formating problem, Steffen Nurpmeso, 2014/04/09
- bug#17196: UTF-8 printf string formating problem, Rich Felker, 2014/04/10
- bug#17196: UTF-8 printf string formating problem, Steffen Nurpmeso, 2014/04/10
- bug#17196: UTF-8 printf string formating problem, Chet Ramey, 2014/04/10