Orson R. L. Peters builds a state machine that reads UTF-8 one byte at a time. He keeps more states than a yes-or-no validator needs. Those extra states let the scanner tell callers where the valid prefix ends and let the CPU work on two chunks at once.
- Remember the partial character. The state records how many bytes of an unfinished code point the scanner has read. If the next byte is invalid, the scanner can report the end of the last complete code point.
- Overlap the scans by four bytes. The first scan checks the shared bytes. The second uses them to find a character boundary, so it can start before the first scan finishes.
- Pack the transition table. Each byte selects a word, and the current state selects how far to shift it. A constraint solver packs the table into 1 KiB, half the size of the earlier 64-bit layout.
On Chinese text on an Apple M5, Peters reports that the example ran nine times as fast as Höhrmann’s minimal C validator. It still took about 2.5 times as long as simdutf and lacks an ASCII fast path. Benchmark your own text mix and test malformed input at chunk boundaries before swapping validators.