1 // Copyright 2014 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/runes"
12 "golang.org/x/text/transform"
13 "golang.org/x/text/unicode/norm"
14 "golang.org/x/text/width"
17 func ExampleRemove() {
18 t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
19 s, _, _ := transform.String(t, "résumé")
27 replaceHyphens := runes.Map(func(r rune) rune {
28 if unicode.Is(unicode.Hyphen, r) {
33 s, _, _ := transform.String(replaceHyphens, "a-b‐c⸗d﹣e")
41 // Convert Latin characters to their canonical form, while keeping other
42 // width distinctions.
43 t := runes.If(runes.In(unicode.Latin), width.Fold, nil)
44 s, _, _ := transform.String(t, "アルアノリウ tech / アルアノリウ tech")
48 // アルアノリウ tech / アルアノリウ tech
52 // Widen everything but ASCII.
53 isASCII := func(r rune) bool { return r <= unicode.MaxASCII }
54 t := runes.If(runes.Predicate(isASCII), nil, width.Widen)
55 s, _, _ := transform.String(t, "アルアノリウ tech / 中國 / 5₩")
59 // アルアノリウ tech / 中國 / 5₩