Thread overview
[Issue 5265] New: std.array.back does not work correctly for wchar-based arrays
Feb 03, 2013
Andrej Mitrovic
November 24, 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@puremagic.com
        ReportedBy: schveiguy@yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy@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: -------
November 24, 2010
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: -------
February 03, 2013
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


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-03 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: -------
February 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5265


Steven Schveighoffer <schveiguy@yahoo.com> changed:

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


--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2013-02-11 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: -------