Skip to content

Commit 00e3b15

Browse files
committed
update README.md
1 parent 7773bc9 commit 00e3b15

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ This library offers robust string wrapping capabilities with a focus on accurate
2323
* An indication of whether the line ended due to a hard break or soft wrapping.
2424
* A flag indicating if the segment ends with a word that was split during wrapping.
2525

26+
## 💡 **Why Grapheme Clusters Matter**
27+
28+
Both `StringWrap` and `StringWrapSplit` use Unicode grapheme cluster parsing (via the `uniseg` library) rather than simple rune iteration. This is crucial for accurate width calculation with complex Unicode sequences:
29+
30+
* **ZWJ Emojis:** Sequences like "👩‍💻" (woman technologist) contain multiple runes but display as a single character
31+
* **Combining Marks:** Characters like "é" (e + combining acute accent) must be treated as one unit
32+
* **Full-width Characters:** Asian characters and emojis that occupy two columns
33+
34+
While this approach is slower than rune-based processing, it prevents incorrect wrapping that would occur with naive rune counting. For applications requiring precise visual alignment (terminals, editors, formatted output), this accuracy is essential.
35+
2636
## 🚀 **Getting Started**
2737

2838
```bash

0 commit comments

Comments
 (0)