Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Unicode canonical equivalence vs. compatibility
let precomposed = "é"
let decomposed = "e\u{301}"
// `==` for strings means canonically equivalent:
assert(precomposed == decomposed)
let letters = "ffi"
let ligature = ""
// The ligature and its decomposition are *not* canonically equivalent:
assert(letters != ligature)
// But they are *compatible* (used for searching etc.)
import Foundation
== ligature.decomposedStringWithCompatibilityMapping)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment