utf8.h icon indicating copy to clipboard operation
utf8.h copied to clipboard

provide get codepoint visual width function

Open duarm opened this issue 2 years ago • 1 comments

Unicode characters can have different visual widths, it would help if utf8.h had a builtin function to retrieve that.

A simple implementation can be found here. https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

simple usage of the above code with utf8.h

int codepoint;
void *v = utf8codepoint(text_ptr, &codepoint);
int w = mk_wcwidth((wchar_t)codepoint);

duarm avatar Jan 09 '23 02:01 duarm

Happy to accept a PR that added something like utf8codepointvisualwidth that does this.

sheredom avatar Jan 10 '23 15:01 sheredom