Skip to content

Incorrect output for certain grapheme clusters #75

Description

@JoshuaWise

In my terminal (Terminal.app), I can write the string:

ᄀᄀᄀᄀᄀᄀ

Which consists of 6 instances of the code point U+1161 (a Korean character), as a single grapheme cluster.

In my terminal, each code point takes up 2 columns visually, for a total of 12 columns. But string-width reports the entire string as just being 2 columns wide. This seems like a bug.

I looked at the source code, and the culprit seems to be here: https://github.com/sindresorhus/string-width/blob/main/index.js#L111 , where it's just looking at the first code point of the grapheme cluster, rather than counting all of them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions