Commit d433c70
Add emoji display width support and width-aware string truncation
mk_wcwidth() returns 0 for emoji codepoints (U+1F300-U+1FAFF) because
they fall through as unassigned. Modern terminals render these as
2-cell-wide characters, causing column misalignment in any application
that relies on mk_wcwidth() for layout.
Add explicit width mappings:
- Emoji pictographs (U+1F300-U+1F9FF, U+1FA00-U+1FAFF): width 2
- Arrows, geometric shapes, dingbats, misc symbols: width 1
- Variation selectors (U+FE00-U+FE0F): width 0
Add utf8_truncate_to_width() which truncates a UTF-8 string to fit
within a target number of display columns, ensuring multi-byte
sequences are never split mid-character.1 parent 3da1534 commit d433c70
2 files changed
+44
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
302 | 327 | | |
303 | 328 | | |
304 | 329 | | |
| |||
316 | 341 | | |
317 | 342 | | |
318 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
319 | 361 | | |
320 | 362 | | |
321 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
0 commit comments