sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.73k stars 125 forks source link

Support constexpr? #91

Closed Guekka closed 2 years ago

Guekka commented 2 years ago

Hey, thanks for this library. I'd like to be able to use it in constexpr context. Would be willing to add a utf8_constexpr macro, that would be used in contexts that would allow it? I might be able to work on a PR, but I don't have a time estimate

sheredom commented 2 years ago

As long as that wouldn't regress any of the C support, then that's fine. Please add some C++11 / 17 (or whatever version you need!) tests for these too 😄

Guekka commented 2 years ago

Hello, I started to work on it. @sheredom, is there a reason that some functions cast strings to unsigned char instead of char? It is preventing me to add constexpr to these functions (for example utf8cmp)

sheredom commented 2 years ago

I think the compares for the ordering requirement it had to be explicitly unsigned (but I'm only vaguely remembering the constraints).