How can I make printf to align values into columns even with non-ascii characters?
The following commands should align values in the 2nd and 3rd paramter to fixed 20-character width:
printf "%-20s %-20s\n" "Foo" "Bar"
printf "%-20s %-20s\n" "Fooo" "Bar"
printf "%-20s %-20s\n" "Foooó" "Bar"
printf "%-20s %-20s\n" "Foooóó" "Bar"
I would expect the following to be printed:
Foo Bar
Fooo Bar
Foooó Bar
Foooóó Bar
In reality, this gets printed:
Foo Bar
Fooo Bar
Foooó Bar
Foooóó Bar
For some reason any non-ascii character (such as ó in my example) shortens the column by 1 character.