I’m writing a simple library where I need to know if a character is fullwidth:
I was surprised this wasn’t in the standard language and implemented a naive solution that just checks if a character is between the appropriate Unicode codepoints.
@josevalim I’m interested in a) have you considered adding this function? and b) if you didn’t think so, why not?
As an extension, getting the fullwidth of a string would be cool. For example:
assert 10 == Width.string("안녕하세요")
Not taking care of fullwidth characters can make CLI output not fit in decorations like boxes or tables.
Just a random idea I had. My library works for me, but if this isn’t a niche use I’d like to see it in the language Thanks for Elixir!
This is a great idea, but I believe that, similar to earlier proposals to find out other properties of unicode characters, we rather will want to add it to a package than to the core language itself.
The reason for this is that writing functions that handle all of unicode means that we have to store a lot of information about characters or character groups in the compiled binaries. This can result in executables that become impossible to use on embedded platforms such as a Raspberry Pi.
After previous discussions about this, a package called unicode was made. It knows some of the simple information about characters. Iirc, checking if a character is fullwidth is not one of them, but would be a great addition.