Using Ruby, I have to output strings in an columnar format to the terminal. Something like this:
| row 1 | a string here | etc
| row 2 | another string | etc
I can do this fine with Latin UTF8 characters using String#ljust and %s.
But a problem arises when the characters are Korean, Chinese, etc. The columns simply won't align when there are rows of English interspersed with rows containing Korean, etc.
How can I get column alignment here? Is there a way to output Asian characters in the equivalent of a fixed-width font? How about for documents that are meant to be displayed and edited in Vim?
'guifontwide'
setting that enables you to choose a double-width font for asian text. – Ogrelen()
is greater then 1 (for example,«
). If it is, then to get real length of the text, uselen(split(str, '\zs'))
instead oflen(str)
(vim-7.2,strwidth(str)
on vim-7.3). – Heatherheatherly