Bug 11713 – std.string munch() does not properly handle UTF strings.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-09T09:51:00Z
Last change time
2013-12-10T13:34:34Z
Assigned to
nobody
Creator
heartcollector87
Comments
Comment #0 by heartcollector87 — 2013-12-09T09:51:56Z
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?
Comment #1 by francesco.cattoglio — 2013-12-09T12:14:06Z