3 ms·
Oh my, I've waited so long to add the utf8 API to my safelibc, but this not what I expected. It's amateur level. int utf8byte(char*) should be named utf8c
by rurban 8y ago
Oh my, I've waited so long to add the utf8 API to my safelibc, but this not what I expected. It's amateur level.
int utf8byte(char*)
should be named utf8cp of course. A 32bit int "byte" codepoint is a bit hard to swallow.
utf8 iterators proved to be wrong in a myriad of previous cases, e.g. libunistring which is still not used in coreutils over this wrong design decision. You do the whole high-level API in buffers by yourself and don't do it with exposed iterators.
casefolding and normalization is only one of the expected features, the next would be identifier safety, which requires a bit more checks. left to right R2L mixups, script mixups, confusables ...
The kernel deals with identifiable strings and once you open the unicode floodgates others will rush in. You really need to think the API through, not like this. At least they thought about the UNICODE_VERSION, which others didn't.
- comex 8y agoThe function does in fact return an (unsigned) byte; the use of int is apparently because it returns -1 on failure. I'm not a big fan of overloading return values that way, but it is reasonably common...