4 ms·
What do you mean? How else would you implement a check for whether the prefix length is valid?
by d33 9y ago
What do you mean? How else would you implement a check for whether the prefix length is valid?
- loeg 9y agoHere's the code to do it: https://github.com/skeeto/branchless-utf8/blob/master/utf8.h https://github.com/skeeto/branchless-utf8/blob/master/utf8.h It's pretty straightforward. He uses a lookup table for the first byte ("lengths") and then later checks that subsequent bytes have the correct continuation prefix (0xc0 mask / 0x2a value). I think it checks all of the same conditions as your Lua code.