Structure

Unicode.Scalar

A Unicode scalar value.

Overview

The Unicode.Scalar type, representing a single Unicode scalar value, is the element type of a string’s unicodeScalars collection.

You can create a Unicode.Scalar instance by using a string literal that contains a single character representing exactly one Unicode scalar value.

let letterK: Unicode.Scalar = "K"
let kim: Unicode.Scalar = "김"
print(letterK, kim)
// Prints "K 김"

You can also create Unicode scalar values directly from their numeric representation.

let airplane = Unicode.Scalar(9992)
print(airplane)
// Prints "✈︎"

Topics

Initializers

init(UInt8)

Creates a Unicode scalar with the specified numeric value.

init(Unicode.Scalar)

Creates a duplicate of the given Unicode scalar.

init?(UInt32)

Creates a Unicode scalar with the specified numeric value.

init?(UInt16)

Creates a Unicode scalar with the specified numeric value.

init?(Int)

Creates a Unicode scalar with the specified numeric value.

init(unicodeScalarLiteral: Unicode.Scalar)

Creates a Unicode scalar with the specified value.

Instance Properties

var customMirror: Mirror

A mirror that reflects the Unicode.Scalar instance.

var debugDescription: String

An escaped textual representation of the Unicode scalar, suitable for debugging.

var description: String

A textual representation of the Unicode scalar.

var hashValue: Int

The Unicode scalar’s hash value.

var isASCII: Bool

A Boolean value indicating whether the Unicode scalar is an ASCII character.

var value: UInt32

A numeric representation of the Unicode scalar.

Instance Methods

func escaped(asASCII: Bool)

Returns a string representation of the Unicode scalar.

func write<Target>(to: inout Target)

Writes the textual representation of the Unicode scalar into the given output stream.

Operator Functions

static func !=(Unicode.Scalar, Unicode.Scalar)

Returns a Boolean value indicating whether two values are not equal.

static func ...(Unicode.Scalar)

Returns a partial range up to, and including, its upper bound.

static func ...(Unicode.Scalar)

Returns a partial range extending upward from a lower bound.

static func ..<(Unicode.Scalar)

Returns a partial range up to, but not including, its upper bound.

static func <=(Unicode.Scalar, Unicode.Scalar)

Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.

static func >(Unicode.Scalar, Unicode.Scalar)

Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.

static func >=(Unicode.Scalar, Unicode.Scalar)

Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.