Textwrap will now use the Unicode Linebreaking algorithm by default, courtesy of the unicode-linebreak crate. Before, words were found by splitting on space, now they are found using the Unicode break properties. This allows breaking East-Asian text like
"好". It also allows breaking a string of emojis like
"😍". The Unicode line breaking algorithm also prevents breaks in certain cases, such as in
"Bonjour !"where French punctuation rules require a non-breaking space before
The demo shows how Textwrap can be used to wrap both proportional and fixed-width text. In the demo, the text is rendered on a HTML canvas element, but it could just as well go to a PDF file, a GUI, or similar. The ability to wrap text outside of the terminal was added in version 0.13.0.
Please give it a spin and let me know of any problems!