www.digitalmars.com         C & C++   DMDScript  

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

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


--- Comment #0 from heartcollector87 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: -------
Dec 09 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11713


Francesco Cattoglio <francesco.cattoglio gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |francesco.cattoglio gmail.c
                   |                            |om


--- Comment #1 from Francesco Cattoglio <francesco.cattoglio gmail.com>
2013-12-09 12:14:06 PST ---
pull request: https://github.com/D-Programming-Language/phobos/pull/1760

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11713



--- Comment #2 from Francesco Cattoglio <francesco.cattoglio gmail.com>
2013-12-09 13:33:43 PST ---
(In reply to comment #1)
 pull request: https://github.com/D-Programming-Language/phobos/pull/1760
Modified munch() unittest adding a (small) test case. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 09 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11713


Francesco Cattoglio <francesco.cattoglio gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Francesco Cattoglio <francesco.cattoglio gmail.com>
2013-12-10 13:34:34 PST ---
fixed in https://github.com/D-Programming-Language/phobos/pull/1760

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