qnet.utils.unicode module

Utils for working with unicode strings

Summary

Functions:

grapheme_len Number of graphemes in text
ljust Left-justify text to a total of width
rjust Right-justify text for a total of width graphemes

Reference

qnet.utils.unicode.grapheme_len(text)[source]

Number of graphemes in text

This is the length of the text when printed::
>>> s = 'Â'
>>> len(s)
2
>>> grapheme_len(s)
1
qnet.utils.unicode.ljust(text, width, fillchar=' ')[source]

Left-justify text to a total of width

The width is based on graphemes:

>>> s = 'Â'
>>> s.ljust(2)
'Â'
>>> ljust(s, 2)
'Â '
qnet.utils.unicode.rjust(text, width, fillchar=' ')[source]

Right-justify text for a total of width graphemes

The width is based on graphemes:

>>> s = 'Â'
>>> s.rjust(2)
'Â'
>>> rjust(s, 2)
' Â'