|
|
|
|
|
by masklinn
3947 days ago
|
|
> Simple enough, in essence given first argument, print it up to length 12. As an added this also deals with unicode correctly That's not true, Python 3 uses codepoint-based indexing but it will break if combining characters are involved. For instance: > python3 test.py देवनागरीदेवनागरी
देवनागरीदेवन
because there is no precombined version of the multi-codepoint grapheme clusters so some of these 10 user-visible characters takes more than a single you end up with 8 user-visible characters rather than the expected 10.edit: the original version used the input string "ǎěǐǒǔa̐e̐i̐o̐u̐ȃȇȋȏȗ" where clusters turn out to have precomposed versions after all. Replaced it by devanāgarī repeated once (in the devanāgarī script) |
|
[1]: https://pypi.python.org/pypi/regex