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.
Comment #1 by issues.dlang — 2012-10-24T22:37:26Z
Comment #2 by github-bugzilla — 2013-01-04T15:02:33Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/dd5eb5ff97736ecaec525488413382f94c0053ea Fix for issue# 8890: commonPrefix does not handle unicode correctly. It was returning partial code points if the first few code units in a code point matched but not the entire code point. https://github.com/D-Programming-Language/phobos/commit/2aa1295f4d1b884713e7465b4c1f48d926d936b3 Merge pull request #889 from jmdavis/8890 Fix for issue# 8890: commonPrefix does not handle unicode correctly.
Comment #3 by issues.dlang — 2013-01-07T02:14:01Z
*** Issue 8754 has been marked as a duplicate of this issue. ***