[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: printf doesn't work properly for non-ASCII



On Wed, Mar 10, 2004 at 03:35:07PM +0200, Anton Zinoviev wrote:
> Hi!
> 
> I decided to try how partman works with localised strings and observed
> that some of the strings almost overlap on the screen.  Investigation
> showed that this was caused by printf.
> 
> In several places in the code of partman are used commands like 
> 
> printf "(%5s)\n" $var
> 
> The problem is that printf considers the length of the strings in
> bytes as length in symbols which is not true for UTF-8.  For example
> if var='пя' (two Cyrillic letters) then the quoted printf command will
> output "( пя)" instead of "(   пя)".  For Asian languages the
> situation can be even worse because there 3 or 4 bytes represent only
> one character.
> 
> All versions of printf I tested are broken -- the internal printf
> command in bash, /usr/bin/printf and busybox.  Does someone know how
> this can be fixed?
> 
  Using of wide character functions may help but this will require
rewrite of all code that works with localized strings.



Reply to: