-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-9802] String.subscript using Range with misaligned Index created by UTF8View is not compatible between Swift 4.x and Swift 5 #52226
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
Comments
The printout for
|
@lorentey A9 is the last byte of the UTF-8 sequence, so that's where it's coming from: café.utf8.map { String($0, radix: 16, uppercase: true) }
// ["63", "61", "66", "C3", "A9"] But if you print |
It definitely seems like a bug that Beyond that, the printing of
Granted, I'm not quite sure what this should print, because there's no way to write a string literal that would reproduce the original malformed string, but the best option is probably to just use U+FFFD replacement characters instead of this (the © appears to be interpreting the |
It seems $ pbpaste
func printUnicodeScalars<S: StringProtocol>(_ string: S) {
print(string.unicodeScalars.map {
"\\u{\(String($0.value, radix: 16))}"
}.joined())
}
// https://emojipedia.org/family-man-woman-girl-boy/
let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}"
printUnicodeScalars(family)
let utf16Index = family.utf16.index(before: family.utf16.endIndex)
let utf16Before = String(family[..<utf16Index])
printUnicodeScalars(utf16Before)
let utf16After = String(family[utf16Index...])
printUnicodeScalars(utf16After)
printUnicodeScalars(utf16Before + utf16After)
print(utf16After.utf16.count)
$ pbpaste|xcrun --toolchain org.swift.42120181030a swift -
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{fffd}
\u{fffd}
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}
1
$ pbpaste|xcrun --toolchain org.swift.5020190129a swift -
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}
\u{1f466}
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}
2 |
filed separated issue https://bugs.swift.org/browse/SR-9820 for |
At the same time Native Encoding is switched from |
It seems I misunderstood. |
Not yet, I can look at it this week. |
(I am investigating this and a whole slew of issues as part of https://bugs.swift.org/browse/SR-10124) |
Environment
swift-5.0-DEVELOPMENT-SNAPSHOT-2019-01-28-a
Additional Detail from JIRA
md5: 8de5a32c30085c0bf4d7d4a6037a1cc5
relates to:
Issue Description:
test.swift
from forum post:Results are different between Swift 4.2.1 and 5.0
Swift 4.2.1 is compatible with Swift 4.0.3 and 4.1.3.
Is this change expected ?
/cc: @milseman
The text was updated successfully, but these errors were encountered: