Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese half-width kana dakuten(゙) and han-dakuten(゚) are not counted. #55

Open
sinbino opened this issue Jan 24, 2024 · 2 comments

Comments

@sinbino
Copy link

sinbino commented Jan 24, 2024

Japanese half-width kana dakuten(゙) and han-dakuten(゚) are not counted.

import stringWidth from 'string-width'
console.log(stringWidth('バ')) // => 1
console.log(stringWidth('パ')) // => 1

Since dakuten(゙) and han-dakuten(゚) actually have width, these results should be 2.

@sinbino sinbino changed the title Japanese one-byte kana dakuten(゙) and han-dakuten(゚) are not counted. Japanese half-width kana dakuten(゙) and han-dakuten(゚) are not counted. Jan 24, 2024
@fabiospampinato
Copy link

fabiospampinato commented Feb 26, 2024

@sindresorhus FWIW with my approach of stripping \p{M} characters these test cases seem to pass instead.

@fabiospampinato
Copy link

fabiospampinato commented Feb 26, 2024

It's interesting actually because if Intl.Segmenter is the best way to do this, and Intl.Segmenter sees that as a single segment, what else is missing that would allow us to account for this use case correctly? And once we know what the other missing ingredients are what useful thing is Intl.Segmenter actually doing for us here? 🤔

Like from this example it seems like we don't actually care about "graphemes", and that seems the most granular thing that Intl.Segmenter can segment.

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

No branches or pull requests

2 participants