New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-2413] String.characters not handling some unicode characters correctly #4339
Comments
cc @gribozavr |
IIUC, this is correct behavior as-is. Per UTR #51 skin tone modifiers are separate characters that modify the preceding character if possible. Besides emoji skin tone modifiers there are other Unicode selector characters that work like this; there is no ambiguity in the spec in this respect. |
I think this goes into the general "Unicode 9 character segmentation" bucket. |
Ah you're right, Unicode 9 updated the extended grapheme cluster rules... |
Comment by Jayant Varma (JIRA) Thanks all, but as I understand that Swift aims at making string handling correct in comparison to other languages. While the emoji + skintone are valid in the UTR #51 as referenced above. From a developer's perspective, that should still read as the Emoji which can then be further queried to get the skintone etc as required. If someone is getting the length of the string or working on things like that, then it should work accordingly. Did I understand incorrectly Apple's direction regarding strings? |
You're right about what the optimal segmentation for emoji with skin tone modifiers would be. This issue is addressed in Unicode 9, which Swift will support in the future (as far as I know). |
PR raised for this and other issues apple/swift#6204 |
I think this was fixed when Swift changed the used Unicode version to 9. If so, this should be closed. |
Environment
Xcode Version 8.0 beta 6 (8S201h) with Swift 3.0
Additional Detail from JIRA
md5: 2cb0836048dcca5c9085078157a3d62f
Issue Description:
{{let _str = "Good Coffee <emoji with skin tone here>"
for char in _str.characters {
print(char)
}
/*
This should print the emoji as is, but instead it displays the emoji and the skin tone separately.
G
o
o
d
C
o
f
f
e
e
<emoji - thumbs up>
<skin tone>
*/
}}
On a side note, could not post the issue with the emojis on JIRA 🙁
The text was updated successfully, but these errors were encountered: