Created
September 27, 2021 21:42
-
-
Save ole/a54e9d5aa25f9c5350a9767be85158d9 to your computer and use it in GitHub Desktop.
Unicode canonical equivalence vs. compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let precomposed = "é" | |
let decomposed = "e\u{301}" | |
// `==` for strings means canonically equivalent: | |
assert(precomposed == decomposed) | |
let letters = "ffi" | |
let ligature = "ffi" | |
// The ligature and its decomposition are *not* canonically equivalent: | |
assert(letters != ligature) | |
// But they are *compatible* (used for searching etc.) | |
import Foundation | |
assert(letters.decomposedStringWithCompatibilityMapping | |
== ligature.decomposedStringWithCompatibilityMapping) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment