Difference between dstring and string format specifiers support. Bug?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 9 01:20:42 PST 2016
On 11/09/2016 12:21 AM, Vadim Lopatin wrote:
> Looks like bug.
> dchar[] and wchar[] format strings support less specifiers than char[]
>
> import std.format;
> string test1 = "%02d".format(1); // works
> assert(test1 == "01");
> dstring test2 = "%d"d.format(1); // works
> assert(test2 == "1"d);
> wstring test3 = "%02d"w.format(1); // fails
> assert(test3 == "01"w);
> dstring test4 = "%02d"d.format(1); // fails
> assert(test4 == "01"d);
>
It's a bug that std.format uses arrayPtrDiff() here:
https://github.com/dlang/phobos/blob/master/std/format.d#L993
arrayPtrDiff() is at the bottom of the same file but works correctly
only for char strings:
https://github.com/dlang/phobos/blob/master/std/format.d#L6573
Please report it.
Ali
More information about the Digitalmars-d-learn
mailing list