Structure

Unicode.Scalar

A Unicode scalar value.

Declaration

struct Scalar

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 customPlaygroundQuickLook: PlaygroundQuickLook

A custom playground Quick Look for the Unicode.Scalar instance.

Deprecated
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 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) -> String

Returns a string representation of the Unicode scalar.

func hash(into: inout Hasher)

Hashes the essential components of this value by feeding them into the given hasher.

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) -> Bool

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

static func ... (Unicode.Scalar) -> PartialRangeFrom<Unicode.Scalar>

Returns a partial range extending upward from a lower bound.

static func ... (Unicode.Scalar) -> PartialRangeThrough<Unicode.Scalar>

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

static func ... (Unicode.Scalar, Unicode.Scalar) -> ClosedRange<Unicode.Scalar>

Returns a closed range that contains both of its bounds.

static func ..< (Unicode.Scalar) -> PartialRangeUpTo<Unicode.Scalar>

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

static func ..< (Unicode.Scalar, Unicode.Scalar) -> Range<Unicode.Scalar>

Returns a half-open range that contains its lower bound but not its upper bound.

static func <= (Unicode.Scalar, Unicode.Scalar) -> Bool

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) -> Bool

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) -> Bool

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