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

Incorrect width for zhuyin tone marks #7

Open
acarl005 opened this issue Jan 23, 2021 · 1 comment
Open

Incorrect width for zhuyin tone marks #7

acarl005 opened this issue Jan 23, 2021 · 1 comment

Comments

@acarl005
Copy link

acarl005 commented Jan 23, 2021

Thanks for this library. I am building a typing speed training game for Zhuyin (注音) input and this will be convenient.

The tone marks from Zhuyin input are incorrectly having a length of 2 when they should be 1.

const eaw = require("eastasianwidth")

eaw.characterLength("ˋ") // 2
eaw.characterLength("ˇ") // 2
eaw.characterLength("˙") // 2
eaw.characterLength("ˊ") // 2
@seachicken
Copy link

Using icu4j, all these characters are ambiguous, so 2 is correct.

System.out.println(UCharacter.getIntPropertyValue('ˋ', UProperty.EAST_ASIAN_WIDTH)); // UCharacter.EastAsianWidth.AMBIGUOUS;
System.out.println(UCharacter.getIntPropertyValue('ˇ', UProperty.EAST_ASIAN_WIDTH)); // UCharacter.EastAsianWidth.AMBIGUOUS;
System.out.println(UCharacter.getIntPropertyValue('˙', UProperty.EAST_ASIAN_WIDTH)); // UCharacter.EastAsianWidth.AMBIGUOUS;
System.out.println(UCharacter.getIntPropertyValue('ˊ', UProperty.EAST_ASIAN_WIDTH)); // UCharacter.EastAsianWidth.AMBIGUOUS;

If you want 1, you can use eastAsianWidth to determine if 'A' is 1.
Sample implementation: power-assert-util-string-width

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