I filed a bug report: https://issues.dlang.org/show_bug.cgi?id=12923 : "UTF
exception in stride even though passes validate"

and then a proposed fix. The fix still passes unittests and also solves the
bug, however I'm not sure whether it is correct: is the behavior of
strideImpl correct or is the old behavior of decodeImpl correct?

TL;DR:
auto fst=str.front;
immutable msbs = 7 - bsr(~fst);
if (msbs < 2 || msbs > 6) throw invalidUTF();

Reply via email to