Skip to content

Instantly share code, notes, and snippets.

@lucianoschillagi
Created August 26, 2024 14:14
Show Gist options
  • Save lucianoschillagi/45f6165c93d333a202c833d36c63ad40 to your computer and use it in GitHub Desktop.
Save lucianoschillagi/45f6165c93d333a202c833d36c63ad40 to your computer and use it in GitHub Desktop.
Unicode Scalars - Common Chinese characters
import Cocoa
func printCJKUnifiedIdeographs() {
// Define the range of Unicode scalars
// Examples: Common Chinese characters (e.g., 中, 国).
let startScalar = 0x4E00
let endScalar = 0x9FFF
// Iterate over the range and print each character
for scalarValue in startScalar...endScalar {
if let scalar = UnicodeScalar(scalarValue) {
let character = String(scalar)
print("\(scalarValue): \(character)")
} else {
print("\(scalarValue): Invalid scalar")
}
}
}
printCJKUnifiedIdeographs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment