<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Unicode/CanonicalCombiningClass",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UnicodeO23CanonicalCombiningClassV"
  },
  "title" : "Unicode.CanonicalCombiningClass"
}
-->

# Unicode.CanonicalCombiningClass

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

```
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
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)