phobos icon indicating copy to clipboard operation
phobos copied to clipboard

std.format.sformat mishandles wchar ranges

Open dlangBugzillaToGithub opened this issue 3 years ago • 1 comments

ag0aep6g reported this on 2022-11-15T20:15:15Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=23489

Description

Similar to issue 23488, but less urgent for me because I don't use wchars.

struct R
{
    wstring s = "😈";
    bool empty() { return s.length == 0; }
    wchar front() { return s[0]; }
    void popFront() { s = s[1 .. $]; }
}

void main()
{
    import std.format: sformat;
    char[4] buf;
    assert(sformat(buf, "%s", R()) == "😈"); /* fails; should pass */
}

dlangBugzillaToGithub avatar Nov 15 '22 20:11 dlangBugzillaToGithub