I got three UTF-8 stings:
hello, world
hello, ??
hello, ?rld
I only want the first 10 chars so that the bracket in one column:
[hello, wor]
[hello, ? ]
[hello, ?r]
In console:
width('??')==width('worl')
width('? ')==width('wor') #a white space behind '?'
python's format() doesn't help when UTF-8 chars mixed in
>>> for s in ['[{0:<{1}.{1}}]'.format(s, 10) for s in ['hello, world', 'hello, ??', 'hello, ?rld']]:
... print(s)
...
[hello, wor]
[hello, ?? ]
[hello, ?rl]
So, I wonder if there is a standard way to do the UTF-8 padding staff?