Hi everyone!
I just published a small library, Ucwidth to help to detect the display width for any Unicode characters or texts. I think it might be useful if you’re working on something related to text typographing.
Links
Motivation
When developing a terminal-based Elixir application, I found a lack of some library handling character width correctly. Turns out there’s a need to port ucwidth (in C language) to Elixir.
So I made this porting with some additional features.
Key features
- sticking to the latest Unicode standard, and can be updated easily thanks to Elixir’s powerful metaprogramming ability
- Emoji support, even the combined ones
How to use?
Quite simple and straightforward:
iex> Ucwidth.width("👩🔬")
2
iex> Ucwidth.width("H")
1
iex> Ucwidth.width("你好, this is a lovely message 💌!")
34
Feedbacks
I’m not professional at Unicode, just read some specifications and references. Also, this is my first project heavily using metaprogramming (special thanks to the book Metaprogramming Elixir).
So in a word, any comment is welcome!