...
1
2
3
4
5 package width_test
6
7 import (
8 "fmt"
9
10 "golang.org/x/text/width"
11 )
12
13 func ExampleTransformer_fold() {
14 s := "abヲ₩○¥A"
15 f := width.Fold.String(s)
16 fmt.Printf("%U: %s\n", []rune(s), s)
17 fmt.Printf("%U: %s\n", []rune(f), f)
18
19
20
21
22 }
23
24 func ExampleTransformer_widen() {
25 s := "ab¥ヲ₩○"
26 w := width.Widen.String(s)
27 fmt.Printf("%U: %s\n", []rune(s), s)
28 fmt.Printf("%U: %s\n", []rune(w), w)
29
30
31
32
33 }
34
35 func ExampleTransformer_narrow() {
36 s := "abヲ₩○¥A"
37 n := width.Narrow.String(s)
38 fmt.Printf("%U: %s\n", []rune(s), s)
39 fmt.Printf("%U: %s\n", []rune(n), n)
40
41
42 s = "←"
43 n = width.Narrow.String(s)
44 fmt.Printf("%U: %s\n", []rune(s), s)
45 fmt.Printf("%U: %s\n", []rune(n), n)
46
47
48
49
50
51
52 }
53
View as plain text