Bug 8322 – std.string.chomp does not handle combining characters correctly

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-29T22:47:00Z
Last change time
2015-06-09T05:15:16Z
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2012-06-29T22:47:40Z
These two succeed: assert(equal(chomp("hello \u00E9", "\u00E9"), "hello ")); assert(equal(chomp("hello e\u0301", "e\u0301"), "hello ")); These two fail: assert(equal(chomp("hello \u00E9", "e\u0301"), "hello ")); assert(equal(chomp("hello e\u0301", "\u00E9"), "hello ")); It's because chomp makes the erroneous assumption that if a string ends with the delimiter, the code points match exactly.
Comment #1 by issues.dlang — 2012-06-29T23:28:22Z
Scratch this. I was thinking that endsWith was returning true for these and then incorrectly slicing the string when the delimiter was a different set of code points for the saem thing, which would result in it being incorrectly sliced. However, endsWith does _not_ return true for these, because it's operating on code points just like chomp is. In both cases, the strings must be normalized for this to work properly. chomp isn't broken.