UTF-8 Width Display Issue of Chinese Characters
问题 When I use Perl or C to printf some data, I tried their format to control the width of each column, like printf("%-30s", str); But when str contains Chinese character, then the column doesn't align as expected. see the attachment picture. My ubuntu's charset encoding is zh_CN.utf8, as far as I know, utf-8 encoding has 1~4 length of bytes. Chinese character has 3 bytes. In my test, I found printf's format control count a Chinese character as 3, but it actually displays as 2 ascii width. So the