www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - UTF bug+proposed fix, please check

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?

auto fst=str.front;
immutable msbs = 7 - bsr(~fst);
if (msbs < 2 || msbs > 6) throw invalidUTF();
Jun 14 2014