r should be or type io.Reader and you cannot type r like that. First, you need to read the contents in a byte fragment:
var ( s = "Your Śtring" b = make([]byte, len(s)) r io.Reader = strings.NewReader(s) ) t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC) r = transform.NewReader(r, t) r.Read(b) fmt.Println(string(b))
This works, but for some reason returns "Your Stri", two bytes less than necessary.
This is the version that actually does what you need, but I'm still not sure why the blog example works so weird.
s := "Yoùr Śtring" b := make([]byte, len(s)) t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC) _, _, e := t.Transform(b, []byte(s), true) if e != nil { panic(e) } fmt.Println(string(b))
source share