www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12616] New: AssertError in std.utf.decode

https://issues.dlang.org/show_bug.cgi?id=12616

          Issue ID: 12616
           Summary: AssertError in std.utf.decode
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: dmitrycvet gmail.com

Created attachment 1347
  --> https://issues.dlang.org/attachment.cgi?id=1347&action=edit
Frament of torrent file with bug (binary data)

I use std.utf.validate to check validity string of UTF. And i catch
UTFException if string not valid. But... In debug mode i have AssertError:

core.exception.AssertError std.utf(950): Assertion failure


My code:

try {
    root.str = cast(string) store.str;   // from immutable(ubyte)[]
    validate(root.str);
} catch(UTFException e) {
    root.str = toHexString!(LetterCase.upper)(store.str);
}

It work on release mode.

--
Apr 22 2014