digitalmars.D.learn - Difference between dstring and string format specifiers support. Bug?
- Vadim Lopatin (12/12) Nov 09 2016 Looks like bug.
- Vadim Lopatin (3/15) Nov 09 2016 dmd 2.072.0
- =?UTF-8?Q?Ali_=c3=87ehreli?= (8/19) Nov 09 2016 It's a bug that std.format uses arrayPtrDiff() here:
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/7) Nov 09 2016 What I meant is, using arrayPtrDiff() is correct only for char strings.
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);
Nov 09 2016
On Wednesday, 9 November 2016 at 08:21:53 UTC, 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);dmd 2.072.0
Nov 09 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
Nov 09 2016
On 11/09/2016 01:20 AM, Ali Çehreli wrote: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#L6573What I meant is, using arrayPtrDiff() is correct only for char strings. Otherwise, arrayPtrDiff() is working properly. Ali
Nov 09 2016