[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.

This is a feature, not a bug ;)
If you want to print aligned data, you should be aware that not all
characters fit on a cell, some are 0 or 2 column wide; see strwidth
function in cdebconf/src/strutl.c or libtextwrap1.
I do not know if a program exists to do what you want from a shell.

Denis



Reply to: