Thread overview
[Issue 6125] to!string doesn't throw on invalid UTF sequence
May 22, 2014
Behnam Esfahbod
Aug 27, 2016
Andrej Mitrovic
Nov 21, 2016
Lucia Cojocaru
Dec 11, 2019
berni44
Dec 17, 2022
Iain Buclaw
May 22, 2014
https://issues.dlang.org/show_bug.cgi?id=6125

Behnam Esfahbod <dlang@behnam.es> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang@behnam.es

--
August 27, 2016
https://issues.dlang.org/show_bug.cgi?id=6125

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
-----
import std.conv;
import std.stdio;

void main()
{
    auto x = to!string(cast(char)255);
    writeln(x);
}
-----

Outputs:
[Decode error - output not utf-8]

I think the to!() routines should be UTF safe so the call to to!string above should throw an exception. Is this right Andrei?

--
October 14, 2016
https://issues.dlang.org/show_bug.cgi?id=6125

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
Well since it doesn't throw we may as well make it nothrow :o) and use the replacement char, or add an overload. I'll bootcamp this.

--
November 21, 2016
https://issues.dlang.org/show_bug.cgi?id=6125

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

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

--- Comment #3 from Lucia Cojocaru <lucia.mcojocaru@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@src/rt/util/utf.d(292): invalid UTF-8 sequence

--
December 11, 2019
https://issues.dlang.org/show_bug.cgi?id=6125

berni44 <bugzilla@d-ecke.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@d-ecke.de
                 OS|Windows                     |All

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=6125

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--