That's pretty neat! I don't know about passing a pointer to state which gets both modified and returned. I guess it avoids writing if ((state = decode(state, &codepoint, *s)) != UTF8_REJECT) or similar.
-
-
-
You're free to change that, or pass &(uint32_t){state}. Part of what makes this so nice is it's inline and paste/edit friendly if you need to change the interface.
-
Most of the time with byte- or character-at-a-time UTF-8 decoding, the performance bottleneck is the interface to the decoder core, so ease of changing that is a big feature.
-
I took a look at
@rustlang's implementation https://doc.rust-lang.org/src/core/str/mod.rs.html#336 … and I suspect it could be improved by this, but I didn't implement and test. (Also, I think it has two bugs in next_code_point.)
End of conversation
New conversation -
-
-
Hey I know that Rich Felker fellow...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.