mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
stdlib/String: if we can not get a contiguous data buffer out of NSString,
don't call into CoreFoundation to perform UTF-8 transcoding. CoreFoundation can replace ill-formed sequences with a single byte, which is not good enough to implement U+FFFD insertion. Instead, use the same transcoding routine as for contiguous buffer. Pulled out the transcoding routine into a generic function that should be specialized and simplified for the case when input is UnsafeArray; we should not be losing efficiency here. Fixes <rdar://problem/17297055> [unicode] println crashes when given string with unpaired surrogate Swift SVN r19157
This commit is contained in:
@@ -106,7 +106,7 @@ extension String {
|
||||
case .EmptyInput:
|
||||
return .None
|
||||
case .Error:
|
||||
_fatalError("unpaired surrogates are ill-formed in UTF-16")
|
||||
return UnicodeScalar(0xfffd)
|
||||
}
|
||||
}
|
||||
var _decoder: UTF16 = UTF16()
|
||||
|
||||
Reference in New Issue
Block a user