String width is the sum of its code point widths

All 31 scenarios hold

Emoji and CJK render two columns wide, so mixed-script strings are wider than their character count. A null or empty string has width zero.

expected outcome broken scenario
ScenarioTextWidth?
ASCII single letterA1
ASCII wordHello5
ASCII numbers1233
CJK single character2
CJK two characters你好4
CJK four characters你好世界8
Japanese hiraganaこんにちは10
Japanese hiragana with kanjiこんにちは世界14
Korean short greeting안녕4
Korean greeting안녕하세요10
Emoji grinning face😀2
Emoji waving hand👋2
Emoji coffee2
Mixed ASCII and emojiHello 👋 World14
Mixed text with emojiCafé ☕ tastes good19
Scandinavian ææ1
Scandinavian ø repeatedøøø3
Scandinavian å repeatedååå3
Accented word naïvenaïve5
Accented word résumérésumé6
Greek letters with spacesα β γ5
Greek greetingΓεια σου κόσμε14
Cyrillic greetingПривет мир10
Arabic greetingمرحبا بالعالم13
Hebrew greetingשלום עולם9
Mathematical symbols∑ ∏ ∫ √7
Box drawing characters┌─┐│ │└─┘9
Currency symbols$€£¥₹5
Quotation marks«»""''—–8
Null string0
Empty string“”0