[SE-0163] Migrate from deprecated Unicode APIs (part 3) (#33175)

This commit is contained in:
Ben Rimmington
2020-08-06 23:44:55 +01:00
committed by GitHub
parent 69abfc1e6c
commit d3f0de804d
2 changed files with 2 additions and 15 deletions

View File

@@ -172,20 +172,7 @@ public struct StaticString {
return body(UnsafeBufferPointer(
start: utf8Start, count: utf8CodeUnitCount))
} else {
var buffer: UInt64 = 0
var i = 0
let sink: (UInt8) -> Void = {
#if _endian(little)
buffer = buffer | (UInt64($0) << (UInt64(i) * 8))
#else
buffer = buffer | (UInt64($0) << (UInt64(7-i) * 8))
#endif
i += 1
}
UTF8.encode(unicodeScalar, into: sink)
return body(UnsafeBufferPointer(
start: UnsafePointer(Builtin.addressof(&buffer)),
count: i))
return unicodeScalar.withUTF8CodeUnits { body($0) }
}
}