mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib/Unicode: allow transcode() to operate on mutable value-typed
sinks Swift SVN r22302
This commit is contained in:
@@ -97,21 +97,23 @@ public struct _StringBuffer {
|
||||
|
||||
if isAscii {
|
||||
var p = UnsafeMutablePointer<UTF8.CodeUnit>(result.start)
|
||||
let hadError = transcode(encoding, UTF32.self, input.generate(),
|
||||
SinkOf {
|
||||
(p++).memory = UTF8.CodeUnit($0)
|
||||
},
|
||||
stopOnError: !repairIllFormedSequences)
|
||||
var sink = SinkOf<UTF32.CodeUnit> {
|
||||
(p++).memory = UTF8.CodeUnit($0)
|
||||
}
|
||||
let hadError = transcode(
|
||||
encoding, UTF32.self, input.generate(), &sink,
|
||||
stopOnError: !repairIllFormedSequences)
|
||||
_sanityCheck(!hadError, "string can not be ASCII if there were decoding errors")
|
||||
return (result, hadError)
|
||||
}
|
||||
else {
|
||||
var p = result._storage.baseAddress
|
||||
let hadError = transcode(encoding, UTF16.self, input.generate(),
|
||||
SinkOf {
|
||||
(p++).memory = $0
|
||||
},
|
||||
stopOnError: !repairIllFormedSequences)
|
||||
var sink = SinkOf<UTF16.CodeUnit> {
|
||||
(p++).memory = $0
|
||||
}
|
||||
let hadError = transcode(
|
||||
encoding, UTF16.self, input.generate(), &sink,
|
||||
stopOnError: !repairIllFormedSequences)
|
||||
return (result, hadError)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user