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

Substring can't handle utf8 characters #286

Closed
trim21 opened this issue Dec 25, 2022 · 3 comments
Closed

Substring can't handle utf8 characters #286

trim21 opened this issue Dec 25, 2022 · 3 comments

Comments

@trim21
Copy link
Contributor

trim21 commented Dec 25, 2022

package main

import (
	"fmt"

	"github.com/samber/lo"
)

func main() {
	result1 := lo.Substring("你好,世界", 0, 2)

	fmt.Printf("%s\n", result1)
}

https://go.dev/play/p/hvwkx8BQxPN

when processing string, it's expected to do something like this: string(lo.Subset([]rune(s), start, end))

@dolmen
Copy link
Contributor

dolmen commented Feb 23, 2023

Cutting on codepoint boundaries could be counted as wrong as well if combining codepoints are not handled as well.

@samber samber closed this as completed Mar 20, 2023
@trim21
Copy link
Contributor Author

trim21 commented Mar 21, 2023

@samber new release please?

Sorry, saw the new tag.

@samber
Copy link
Owner

samber commented Mar 21, 2023

The v1.38.0 release failed. I just made a new version: v1.38.1.

This issue was closed.
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

Successfully merging a pull request may close this issue.

3 participants