Bug 8890 – std.algorithm.commonPrefix does not handle unicode correctly
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-24T21:31:00Z
Last change time
2013-01-07T02:17:01Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2012-10-24T21:31:11Z
This code asserts:
import std.algorithm;
void main()
{
assert(commonPrefix("Пиво", "Пони")== "П");
}
This is because a portion of the code point following 'П' is returned, because the code units at the beginning of the next code point match, and commonPrefix fails to take that possibility into account. It basically operates on code units right now for matching string types rather than operating on code points as it should.