crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Add support for calculating display width of chars and strings

Open straight-shoota opened this issue 3 years ago • 1 comments

Unicode characters can have different widths. Typical western characters are halfwidth, while some eastern scripts have fullwidth characters (which are twice as wide). To calculate the display width of a character or string, it is paramount to take these character widths into consideration.

A Crystal implementation is already available as a shard in https://github.com/naqvis/uni_char_width It would be great to include this in the standard library because it's universally useful and we have a use case in the compiler (formatter): https://github.com/crystal-lang/crystal/issues/11034

straight-shoota avatar Jul 29 '21 11:07 straight-shoota

This issue has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/print-change-string-size-if-it-take-more-than-one-line/6813/3

crysbot avatar May 05 '24 03:05 crysbot