Dummy Translation wrapper, just returning the same string.
Dummy Plural Translation wrapper, just returning the singular or plural string.
Get the textual width of a utf8 string.
Return the textual width of a utf8 string, chopping it to a specified value. This is what you want to use instead of %.*s, as it does the “right” thing with regard to utf-8 sequences. Eg. “%.*s” % (10, msg) <= becomes => “%s” % (utf8_width_chop(msg, 10))
Expand a utf8 msg to a specified “width” or chop to same. Expansion can be left or right. This is what you want to use instead of %*.*s, as it does the “right” thing with regard to utf-8 sequences. prefix and suffix should be used for “invisible” bytes, like highlighting. Eg. “%-*.*s” % (10, 20, msg)
<= becomes =>
“%s” % (utf8_width_fill(msg, 10, 20)).
“%s” % (utf8_width_fill(msg, 20, 10, left=False)).
“%s” % (utf8_width_fill(msg, 0, 10, prefix=prefix, suffix=suffix)).
Return True/False is the text is valid utf8.
Works like we want textwrap.wrap() to work, uses utf-8 data and doesn’t screw up lists/blocks/etc.
Works like we want textwrap.fill() to work, uses utf-8 data and doesn’t screw up lists/blocks/etc.
convert a ‘str’ to ‘unicode’
convert ‘unicode’ to an encoded utf-8 byte string
Don’t ask don’t tell, only use when you must
Convert something to a string, if it isn’t one.
convert between unicode and not and compare them, w/o warning or being annoying
Convert an exception to a message. This function will convert the exception using to_unicode, unicode, or str, whichever works correctly.
Parameters: | e – an exception |
---|---|
Returns: | a string representation of the exception |