Skip to content

Commit 2cbc14a

Browse files
author
John Holdsworth
committed
.ascii property -> UnicodeScalar?
1 parent 085a53b commit 2cbc14a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

stdlib/public/core/UnicodeScalar.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,15 @@ extension UInt8? {
438438
}
439439
}
440440

441+
/// Converts a UInt8 value into a UnicodeScalar
442+
extension UInt8 {
443+
@_transparent @_alwaysEmitIntoClient
444+
var ascii: UnicodeScalar? {
445+
guard self < 128 else { return nil }
446+
return UnicodeScalar(self)
447+
}
448+
}
449+
441450
/// Extends `FixedWidthInteger` providing initialization from a Unicode scalar.
442451
extension FixedWidthInteger {
443452
/// Initializes a FixedWidthInteger with the value of the provided Unicode scalar.

0 commit comments

Comments
 (0)