Skip to content

Instantly share code, notes, and snippets.

@sh0seo
Created October 21, 2020 14:52
Show Gist options
  • Save sh0seo/076c81114b345c5ed99d16f4bc1bdb04 to your computer and use it in GitHub Desktop.
Save sh0seo/076c81114b345c5ed99d16f4bc1bdb04 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"unicode"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
func isMn(r rune) bool {
return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks
}
func main() {
t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
result, _, _ := transform.String(t, "São Paulo, Brazil. Wien, Österreich.")
fmt.Println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment