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

           Summary: std.algorithm.reverse() problem with Unicode dchar[]
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-12-09 01:32:52 PST ---
This code compiles and runs raising no assert error, so reverse() is giving a
wrong result on a dchar[]:


import std.algorithm: reverse;
void main() {
    dchar[] txt = "\U00000041\U00000308\U00000042"d.dup;
    txt.reverse();
    assert(txt == "\U00000042\U00000308\U00000041"d);
}


txt contains LATIN CAPITAL LETTER A, COMBINING DIAERESIS, LATIN CAPITAL LETTER
B. See bug 7084 for more details.

A more correct output for reversing txt is (LATIN CAPITAL LETTER B, LATIN
CAPITAL LETTER A, COMBINING DIAERESIS):

"\U00000042\U00000041\U00000308"d

or even (LATIN CAPITAL LETTER B, LATIN CAPITAL LETTER A WITH DIAERESIS) (but
this changes the array size and it's not necessary):

"\U00000042\U000000C4"d

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

Reply via email to