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

Ellipsis: avoid Unicode character truncation #520

Open
ccoVeille opened this issue Aug 19, 2024 · 3 comments
Open

Ellipsis: avoid Unicode character truncation #520

ccoVeille opened this issue Aug 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ccoVeille
Copy link
Contributor

While you are working on Ellipsis, please look at the code behavior.

I doubt the code does what is expected with a Unicode character like πŸ§œβ€β™‚οΈ by truncating to Len 1

@samber
Copy link
Owner

samber commented Jan 25, 2025

Yes, I confirm the bug:

is.Equal("1πŸ§œβ€β™‚οΈ234", lo.Ellipsis("1πŸ§œβ€β™‚οΈ234", 5))
is.Equal("1πŸ§œβ€β™‚οΈ2...", lo.Ellipsis("1πŸ§œβ€β™‚οΈ234", 6))

@samber samber added the bug Something isn't working label Jan 25, 2025
@yasuaki640
Copy link

This bug could be fixed by counting the string grapheme cluster at github.com/rivo/uniseg .

If this policy is acceptable, I'll work on a PR for the fix!

@samber
Copy link
Owner

samber commented Jan 28, 2025

Sure.

Please do not import dependency. I keep this repo as lightweight as possible.
A little copy is sometimes better than a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants