Skip to content

Fix grapheme cluster width - #126

Merged
adsr merged 1 commit into
masterfrom
cluster-width
Jan 2, 2026
Merged

Fix grapheme cluster width#126
adsr merged 1 commit into
masterfrom
cluster-width

Conversation

@adsr

@adsr adsr commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

As pointed out in #125, the width of a grapheme cluster is not the sum of the wcwidth of its codepoints. There's no standard way of determining the column width of a grapheme cluster, but the implementation in this commit is a decent real world approximation. Basically, it returns the max wcwidth in the cluster, and tries to account for VS15, VS16, zero-width joiners, and regional indicators, which are common exceptions to this shortcut.

as pointed out in #125, the width of a grapheme cluster is not the
sum of the wcwidth of its codepoints. there's no standard way of
determining the column width of a grapheme cluster, but the
implementation in this commit is a decent real world approximation.
basically, it returns the max wcwidth in the cluster, and tries to
account for vs15, vs16, zero-width joiners, and regional indicators.
@adsr
adsr merged commit 918369f into master Jan 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant