1 // Copyright 2015 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.
10 "golang.org/x/text/width"
13 func ExampleTransformer_fold() {
15 f := width.Fold.String(s)
16 fmt.Printf("%U: %s\n", []rune(s), s)
17 fmt.Printf("%U: %s\n", []rune(f), f)
20 // [U+0061 U+0062 U+FF66 U+FFE6 U+FFEE U+FFE5 U+FF21]: abヲ₩○¥A
21 // [U+0061 U+0062 U+30F2 U+20A9 U+25CB U+00A5 U+0041]: abヲ₩○¥A
24 func ExampleTransformer_widen() {
26 w := width.Widen.String(s)
27 fmt.Printf("%U: %s\n", []rune(s), s)
28 fmt.Printf("%U: %s\n", []rune(w), w)
31 // [U+0061 U+0062 U+00A5 U+FF66 U+20A9 U+FFEE]: ab¥ヲ₩○
32 // [U+FF41 U+FF42 U+FFE5 U+30F2 U+FFE6 U+25CB]: ab¥ヲ₩○
35 func ExampleTransformer_narrow() {
37 n := width.Narrow.String(s)
38 fmt.Printf("%U: %s\n", []rune(s), s)
39 fmt.Printf("%U: %s\n", []rune(n), n)
41 // Ambiguous characters with a halfwidth equivalent get mapped as well.
43 n = width.Narrow.String(s)
44 fmt.Printf("%U: %s\n", []rune(s), s)
45 fmt.Printf("%U: %s\n", []rune(n), n)
48 // [U+0061 U+0062 U+30F2 U+FFE6 U+25CB U+FFE5 U+FF21]: abヲ₩○¥A
49 // [U+0061 U+0062 U+FF66 U+20A9 U+FFEE U+00A5 U+0041]: abヲ₩○¥A