Structure

Unicode.CanonicalCombiningClass

The classification of a scalar used in the Canonical Ordering Algorithm defined by the Unicode Standard.

Declaration

struct CanonicalCombiningClass

Overview

Canonical combining classes are used by the ordering algorithm to determine if two sequences of combining marks should be considered canonically equivalent (that is, identical in interpretation). Two sequences are canonically equivalent if they are equal when sorting the scalars in ascending order by their combining class.

For example, consider the sequence "\u{0041}\u{0301}\u{0316}" (LATIN CAPITAL LETTER A, COMBINING ACUTE ACCENT, COMBINING GRAVE ACCENT BELOW). The combining classes of these scalars have the numeric values 0, 230, and 220, respectively. Sorting these scalars by their combining classes yields "\u{0041}\u{0316}\u{0301}", so two strings that differ only by the ordering of those scalars would compare as equal:

let aboveBeforeBelow = "\u{0041}\u{0301}\u{0316}"
let belowBeforeAbove = "\u{0041}\u{0316}\u{0301}"
print(aboveBeforeBelow == belowBeforeAbove)
// Prints "true"

Named and Unnamed Combining Classes

Canonical combining classes are defined in the Unicode Standard as integers in the range 0...254. For convenience, the standard assigns symbolic names to a subset of these combining classes.

The CanonicalCombiningClass type conforms to RawRepresentable with a raw value of type UInt8. You can create instances of the type by using the static members named after the symbolic names, or by using the init(rawValue:) initializer.

let overlayClass = Unicode.CanonicalCombiningClass(rawValue: 1)
let overlayClassIsOverlay = overlayClass == .overlay
// overlayClassIsOverlay == true

Topics

Type Aliases

typealias Unicode.CanonicalCombiningClass.RawValue

The raw type that can be used to represent all values of the conforming type.

Initializers

init(rawValue: UInt8)

Creates a new canonical combining class with the given raw integer value.

Instance Properties

var hashValue: Int

The hash value.

let rawValue: UInt8

The raw integer value of the canonical combining class.

Type Properties

static let doubleAbove: Unicode.CanonicalCombiningClass

Distinct marks extending above two bases.

static let iotaSubscript: Unicode.CanonicalCombiningClass

Greek iota subscript only (U+0345 COMBINING GREEK YPOGEGRAMMENI).

static let kanaVoicing: Unicode.CanonicalCombiningClass

Combining marks that are attached to hiragana and katakana to indicate voicing changes.

static let notReordered: Unicode.CanonicalCombiningClass

Base glyphs that occupy their own space and do not combine with others.

static let nukta: Unicode.CanonicalCombiningClass

Diacritic nukta marks in Brahmi-derived scripts.

static let overlay: Unicode.CanonicalCombiningClass

Marks that overlay a base letter or symbol.

static let virama: Unicode.CanonicalCombiningClass

Diacritic virama marks in Brahmi-derived scripts.

Instance Methods

func hash(into: inout Hasher)

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

Operator Functions

static func != (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> Bool

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

static func < (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> Bool

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

static func <= (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> 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.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> Bool

Returns a Boolean value indicating whether two values are equal.

static func > (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> Bool

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

static func >= (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass) -> Bool

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

Relationships

See Also

Unicode Scalar Classifications

enum Unicode.GeneralCategory

The most general classification of a Unicode scalar.

enum Unicode.NumericType

The numeric type of a scalar.