[Issue 11713] New: std.string munch() does not properly handle UTF strings.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 9 09:52:00 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11713

           Summary: std.string munch() does not properly handle UTF
                    strings.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: heartcollector87 at gmail.com


--- Comment #0 from heartcollector87 at gmail.com 2013-12-09 09:51:56 PST ---
The assert in the following code fails:
import std.string;
void main() {    
    string munch_me = "€test";
    auto munched = munch(munch_me, "€");
    assert(munch_me != "€test");
}
The "€" is not removed by the munch() function.

my guess is that inside the function
S1 munch(S1, S2)(ref S1 s, S2 pattern)

the following code is used:
foreach (i, c; s)
    {
        if (!inPattern(c, pattern))
        {...}
    }

and the foreach is not able to correctly pass the "€" character to inPattern
function.
Perhaps a "foreach (i, dchar; s)" might produce the correct results?

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


More information about the Digitalmars-d-bugs mailing list