Bird
0
0

Why does Swift's Character type support extended grapheme clusters instead of just Unicode scalars?

hard📝 Conceptual Q10 of 15
Swift - Data Types
Why does Swift's Character type support extended grapheme clusters instead of just Unicode scalars?
ABecause <code>Character</code> only supports ASCII characters
BBecause Unicode scalars are deprecated in Swift
CTo improve performance by storing fewer bytes
DTo correctly represent human-readable characters that may combine multiple Unicode scalars
Step-by-Step Solution
Solution:
  1. Step 1: Understand extended grapheme clusters

    Extended grapheme clusters allow multiple Unicode scalars to combine into a single visible character, like accented letters or emoji sequences.
  2. Step 2: Reason why Swift uses this for Character

    Swift's Character type models what users perceive as a single character, which may be multiple Unicode scalars combined.
  3. Final Answer:

    To correctly represent human-readable characters that may combine multiple Unicode scalars -> Option D
  4. Quick Check:

    Character models user-visible characters, not just scalars [OK]
Quick Trick: Character represents visible characters, not raw Unicode scalars [OK]
Common Mistakes:
  • Thinking Unicode scalars are deprecated
  • Assuming Character only supports ASCII
  • Believing extended grapheme clusters reduce memory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes