[Issue 5265] New: std.array.back does not work correctly for wchar-based arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 24 05:12:35 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5265

           Summary: std.array.back does not work correctly for wchar-based
                    arrays
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-11-24 05:11:09 PST ---
In std.array, back() is the same for both char[] based and wchar[] based
arrays, but wchar[] based arrays are encoded differently than char[] based
ones.  It appears the back() function works in most cases, but fails on a few.

Here is an example (thank you to Stephan):

import std.array;
import std.conv;

void main() {
    dchar c = cast(dchar) 0x10000;
    auto ws = to!wstring(c);
    assert(ws.length == 2);            // decoded as surrogate pair
    assert(ws.back == c);              // fails with decoding error
}

This should be added as a unit test, and back(wstring) should get its own
implementation.

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


More information about the Digitalmars-d-bugs mailing list