I have a question about .asciiValue
property.
Why type is this UInt8
, not Int8
? Are there any specific reasons except that ASCII is non-negative value?
///
/// A character with the value "\r\n" (CR-LF) is normalized to "\n" (LF) and
/// has an `asciiValue` property equal to 10.
///
/// let cr = "\r" as Character
/// // cr.asciiValue == 13
/// let lf = "\n" as Character
/// // lf.asciiValue == 10
/// let crlf = "\r\n" as Character
/// // crlf.asciiValue == 10
@inlinable
public var asciiValue: UInt8? {
if _slowPath(self == "\r\n") { return 0x000A /* LINE FEED (LF) */ }
if _slowPath(!_isSingleScalar || _firstScalar.value >= 0x80) { return nil }
return UInt8(_firstScalar.value)
}
/// A Boolean value indicating whether this character represents whitespace,
/// including newlines.
///
/// For example, the following characters all represent whitespace: