www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: schveiguy yahoo.com



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: -------
Nov 24 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5265


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5265


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |WORKSFORME



13:09:53 PST ---
Works in 2.061. Was a test-case added though? If not it should be put in.

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


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |FIXED



06:58:43 PST ---
It was fixed around June of 2011 by Jonathan Davis.  He simply changed the
implementation from using an incorrect local algorithm to using std.utf.

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