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

Variation Selectors incorrectly modify some StringWidths #50

Closed
rockorager opened this issue Feb 8, 2024 · 1 comment
Closed

Variation Selectors incorrectly modify some StringWidths #50

rockorager opened this issue Feb 8, 2024 · 1 comment

Comments

@rockorager
Copy link

rockorager commented Feb 8, 2024

When a Variation Selector succeeds a character that doesn't support it, the width should not be altered. Currently, uniseg reports a width of 2 for any grapheme which has a VS16 selector in it, regardless if the first rune is an emoji sequence or not.

Example

package main

import (
	"fmt"

	"github.com/rivo/uniseg"
)

func main() {
	// 2
	fmt.Println(uniseg.StringWidth("x\uFE0F"))
}

From the unicode standard:

image

Proposed solution

When encountering a VS16 selector, uniseg should verify that the previous rune is indeed an emoji.

@rivo rivo closed this as completed in 03509a9 Feb 8, 2024
@rivo
Copy link
Owner

rivo commented Feb 8, 2024

True. I did not consider the combination of these selectors with non-emoji characters. The latest commit should fix this.

Thanks for letting me know.

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