In the presence of Objective-C, hasPrefix and hasSuffix have the wrong behaviour.
let b1 = "\u{1F1E7}" // Regional indicator letter B
let b2 = b1+b1 // flag of Barbados
b2.hasPrefix(b1) // returns true
b2.hasSuffix(b1) // returns true
According to Unicode rules, the grapheme cluster from string b1 is not present in string b2, as there is should be no grapheme cluster break between the two instances of \u{1F1E7} in b2. (http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules).
Both functions should return false in the example above.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Standard Library | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 42c209e3a14e2350b7530adf1f1fb8baIssue Description:
In the presence of Objective-C, hasPrefix and hasSuffix have the wrong behaviour.
According to Unicode rules, the grapheme cluster from string b1 is not present in string b2, as there is should be no grapheme cluster break between the two instances of \u{1F1E7} in b2. (http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules).
Both functions should return false in the example above.