Created
August 26, 2024 14:14
-
-
Save lucianoschillagi/45f6165c93d333a202c833d36c63ad40 to your computer and use it in GitHub Desktop.
Unicode Scalars - Common Chinese characters
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
| 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