I’m trying to use printf to give a tabulated format to my output, like
printf “%20s %10s %10s”, title, author, date
being title, author and date string variables. The text contained in
these variables is uft-8 encoded, and this makes printf to misalign
the outupt. The reason is that one multi-byte char (for example, a two-
byte char) is counted as several chars (two chars), and thus the
number of spaces required for padding is wrongly calculated.
I searched for discussions about ruby and utf8, and in general it does
not appear as an easy issue. I read abou the String#char proxy
introduced by rails, but I’m not using rails, and in addition I think
it would be of no help here.
Do you know any solution to my problem? The use of printf it is not a
requisite, all what I want if to align the output in columns, without
Thanks in advance,