python 3 and Unicode line breaking
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Jan 14 20:28:10 EST 2011
On Fri, 14 Jan 2011 14:26:09 -0800, leoboiko wrote:
...
> As for taking the time to provide information, I wonder if there was any
> technical problem that prevented you from seeing my reply to Stefan,
> sent Jan 14, 12:29PM?
Presumably, since I haven't got it in my news client. This is not the
first time.
> He asked how exacly the stdlib module “textwrap”
> differs from the Unicode algorithm, so I provided some commented
> examples.
Does this help?
http://packages.python.org/kitchen/api-text-display.html
kitchen.text.display.wrap(text, width=70, initial_indent=u'',
subsequent_indent=u'', encoding='utf-8', errors='replace')
Works like we want textwrap.wrap() to work
[...]
textwrap.wrap() from the python standard libray has two drawbacks
that this attempts to fix:
1. It does not handle textual width. It only operates on bytes or
characters which are both inadequate (due to multi-byte and
double width characters).
2. It malforms lists and blocks.
--
Steven
More information about the Python-list
mailing list