golang/go

x/text: iterator does not handle zero width joiner

Open

#60.522 geöffnet am 30. Mai 2023

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (19.008 Forks)batch import
ExpertNeededNeedsInvestigationhelp wanted

Repository-Metriken

Stars
 (133.883 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

I'm using the go playground

What did you do?

package main

import (
	"fmt"

	"golang.org/x/text/unicode/norm"
)

func main() {
	var ia norm.Iter
	s := "👩🏾‍🦰👱🏾🧑🏾‍⚖️"

	ia.InitString(norm.NFD, s)
	rev := ""

	for !ia.Done() {
		n := ia.Next()
		rev = string(n) + rev
	}

	fmt.Println(rev)
}

Playground: https://go.dev/play/p/Jq9CnUd2zA8

What did you expect to see?

It should print 🧑🏾‍⚖️👱🏾👩🏾‍🦰

I think it has to do with the library not handling zero width joiners. If I use this string: "😀😂" it works as expected.

What did you see instead?

️⚖‍🏾🧑🏾👱🦰‍🏾👩

Contributor Guide