github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/x/text/transform/examples_test.go (about) 1 // Code generated by running "go run gen.go -core" in golang.org/x/text. DO NOT EDIT. 2 3 // Copyright 2013 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package transform_test 8 9 import ( 10 "fmt" 11 "unicode" 12 13 "github.com/icodeface/tls/internal/x/text/transform" 14 "github.com/icodeface/tls/internal/x/text/unicode/norm" 15 ) 16 17 func ExampleRemoveFunc() { 18 input := []byte(`tschüß; до свидания`) 19 20 b := make([]byte, len(input)) 21 22 t := transform.RemoveFunc(unicode.IsSpace) 23 n, _, _ := t.Transform(b, input, true) 24 fmt.Println(string(b[:n])) 25 26 t = transform.RemoveFunc(func(r rune) bool { 27 return !unicode.Is(unicode.Latin, r) 28 }) 29 n, _, _ = t.Transform(b, input, true) 30 fmt.Println(string(b[:n])) 31 32 n, _, _ = t.Transform(b, norm.NFD.Bytes(input), true) 33 fmt.Println(string(b[:n])) 34 35 // Output: 36 // tschüß;досвидания 37 // tschüß 38 // tschuß 39 }