Structure

UnicodeScalar

A Unicode scalar value.

Overview

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

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

let letterK: UnicodeScalar = "K"
let kim: UnicodeScalar = "김"
print(letterK, kim)
// Prints "K 김"

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

let airplane = UnicodeScalar(9992)
print(airplane)
// Prints "✈︎"

Symbols

Initializers

init(UInt8)

Creates a Unicode scalar with the specified numeric value.

init(UnicodeScalar)

Creates a duplicate of the given Unicode scalar.

init?(UInt32)

Creates a Unicode scalar with the specified numeric value.

init?(Int)

Creates a Unicode scalar with the specified numeric value.

init?(String)
init?(UInt16)

Creates a Unicode scalar with the specified numeric value.

init(unicodeScalarLiteral: UnicodeScalar)

Creates a Unicode scalar with the specified value.

Instance Properties

var customMirror: Mirror

A mirror that reflects the UnicodeScalar instance.

var customPlaygroundQuickLook: PlaygroundQuickLook
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 utf16: UnicodeScalar.UTF16View
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.