crystal
crystal copied to clipboard
Add support for calculating display width of chars and strings
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
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