www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11068] New: raw formatting of chars and strings is wrong

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11068

           Summary: raw formatting of chars and strings is wrong
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: monarchdodra gmail.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2013-09-19 00:24:40 PDT ---
//----
    foreach(C ; TypeTuple!(char, wchar, dchar))
    {
        auto app = appender!string();
        formattedWrite(app, "[%r] [%r]", cast(C)'a', to!(const(C)[])("aa"));
        writefln("[%(%x, %)]", app.data().representation());
    }
//----

//What I expected
[5b, 61, 5d, 20, 5b, 61, 61, 5d]
[5b, 61, 0, 5d, 20, 5b, 61, 0, 61, 0, 5d]
[5b, 61, 0, 0, 0, 5d, 20, 5b, 61, 0, 0, 0, 61, 0, 0, 0, 5d]

//What I got
[5b, 61, 0, 0, 0, 5d, 20, 5b, 61, 61, 5d]
[5b, 61, 0, 0, 0, 5d, 20, 5b, 61, 61, 5d]
[5b, 61, 5d, 20, 5b, 61, 61, 5d]

//----
    foreach(C ; TypeTuple!(char, wchar, dchar))
    {
        auto app = appender!string();
        formattedWrite(app, "%r", to!(const(C)[])("日本語"));
        writefln("[%(%x, %)]", app.data().representation());
    }
//----

//What I expected
[e6, 97, a5, e6, 9c, ac, e8, aa, 9e] //9 UTF code units
[e5, 65, 2c, 67, 9e, 8a] //3 2-Byte code units
[e5, 65, 0, 0, 2c, 67, 0, 0, 9e, 8a, 0, 0] //3 4 byte code units

//What I got.
[e5, 65, 0, 0, 2c, 67, 0, 0, 9e, 8a, 0, 0]
[e5, 65, 0, 0, 2c, 67, 0, 0, 9e, 8a, 0, 0]
[e5, 65, 0, 0, 2c, 67, 0, 0, 9e, 8a, 0, 0]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11068


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-09-19 18:54:28 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1588

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11068



--- Comment #2 from github-bugzilla puremagic.com 2013-09-19 18:54:42 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/2d7fc3d5d6a6b29d0c1aff1cb5365f247e25b68d
Merge pull request #1588 from monarchdodra/formatRaw

Fix Issue 11068 - raw formatting of chars and strings is wrong

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11068


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2013