1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 "golang.org/x/text/transform"
12 "golang.org/x/text/unicode/norm"
15 func ExampleRemoveFunc() {
16 input := []byte(`tschüß; до свидания`)
18 b := make([]byte, len(input))
20 t := transform.RemoveFunc(unicode.IsSpace)
21 n, _, _ := t.Transform(b, input, true)
22 fmt.Println(string(b[:n]))
24 t = transform.RemoveFunc(func(r rune) bool {
25 return !unicode.Is(unicode.Latin, r)
27 n, _, _ = t.Transform(b, input, true)
28 fmt.Println(string(b[:n]))
30 n, _, _ = t.Transform(b, norm.NFD.Bytes(input), true)
31 fmt.Println(string(b[:n]))