The classification of a scalar used in the Canonical Ordering Algorithm defined by the Unicode Standard.
SDK
- Xcode 10.2+
Framework
- Swift Standard Library
Declaration
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:
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 Canonical
type conforms to Raw
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(raw
initializer.