1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| package main
import "fmt"
func main() {
s := "你好世界!你好中国"
fmt.Printf("%2s %1s %4s %4s %5s %6s %4s\n", "i", "%c", "%x", "%X", "%v", "%U", "%q")
for i, v := range s {
fmt.Printf("%2d,%c,%x,%X,%v,%U,%q\n", i, v, v, v, v, v, v)
}
}
Output:
i %c %x %X %v %U %q
0,你,4f60,4F60,20320,U+4F60,'你'
3,好,597d,597D,22909,U+597D,'好'
6,世,4e16,4E16,19990,U+4E16,'世'
9,界,754c,754C,30028,U+754C,'界'
12,!,ff01,FF01,65281,U+FF01,'!'
15,你,4f60,4F60,20320,U+4F60,'你'
18,好,597d,597D,22909,U+597D,'好'
21,中,4e2d,4E2D,20013,U+4E2D,'中'
24,国,56fd,56FD,22269,U+56FD,'国'
|