Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide get codepoint visual width function #107

Open
duarm opened this issue Jan 9, 2023 · 1 comment
Open

provide get codepoint visual width function #107

duarm opened this issue Jan 9, 2023 · 1 comment

Comments

@duarm
Copy link

duarm commented Jan 9, 2023

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 duarm changed the title provide character visual width functions provide get codepoint visual width function Jan 9, 2023
@sheredom
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants