[Issue 6125] to!string doesn't throw on invalid UTF sequence

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 21 05:36:26 PST 2016


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

Lucia Cojocaru <lucia.mcojocaru at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lucia.mcojocaru at gmail.com

--- Comment #3 from Lucia Cojocaru <lucia.mcojocaru at gmail.com> ---
Is this a Windows specific bug?

I tested the following on Linux 64:
  1 import std.conv;
  2 import std.stdio;
  3 import std.utf;
  4 
  5 void main()
  6 {
  7     auto x = to!string(cast(char)191);
  8     auto z = toUTF8(x);
  9     writeln(x);
 10 
 11 
 12     foreach (y; 0 .. 16)
 13         foreach (r; 0 .. 16)
 14         {
 15             auto buffer = to!string(cast(char)(16 * r + y));
 16             auto b = toUTF8(buffer);
 17             writeln(b);
 18 //            auto result = buffer.toUTF16z;  // call to utf16z for the
winapi
 19         }
 20 }


Only the commented line throws:
core.exception.UnicodeException at src/rt/util/utf.d(292): invalid UTF-8 sequence

--


More information about the Digitalmars-d-bugs mailing list