We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 437302f commit b651278Copy full SHA for b651278
stdlib/public/core/UnicodeScalar.swift
@@ -337,8 +337,8 @@ extension Unicode.Scalar {
337
/// }
338
@inlinable
339
public init?(_ v: Int) {
340
- if let us = Unicode.Scalar(UInt32(v)) {
341
- self = us
+ if let exact = UInt32(exactly: v) {
+ self.init(exact)
342
} else {
343
return nil
344
}
validation-test/stdlib/Unicode.swift.gyb
@@ -210,6 +210,8 @@ UnicodeScalarTests.test("init") {
210
expectEqual("h", UnicodeScalar(UInt16(104)))
211
expectEqual("i", UnicodeScalar(UInt8(105)))
212
expectEqual(nil, UnicodeScalar(UInt32(0xD800)))
213
+ expectEqual("j", Unicode.Scalar(Int(0x6A)))
214
+ expectEqual(nil, Unicode.Scalar(-0x6A))
215
216
217
var UTF8Decoder = TestSuite("UTF8Decoder")
0 commit comments