www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15888] New: std.format generates broken hex strings for


          Issue ID: 15888
           Summary: std.format generates broken hex strings for wchar[]
                    and dchar[] with invalid values
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

void main()
    import std.stdio: writeln;

    ushort[] a = [0xFF_FE, 0x42];
    writeln([cast(wchar[]) a]);

    uint[] b = [0x0F_FF_FF_FF, 0x42];
    writeln([cast(dchar[]) b]);

[x"FFFE 42"w]
[x"FFFFFFF 42"d]

Should print something like this:
[x"FEFF 4200"w]
[x"FFFFFF0F 42000000"d]

Or, since endianess matters:
[[wchar(0xFFFE), 0x42]]
[[dchar(0xFFFFFFF), 0x42]]

Mind issue 15887, though.

Apr 06 2016