1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"unicode/utf8"
)
func ExampleDecodeLastRune() {
b := []byte("Hello, δΈη")
utf8.DecodeLastRune(b)
for len(b) > 0 {
r, size := utf8.DecodeLastRune(b)
fmt.Println("%c %v\n", r, size)
b = b[:len(b)-size]
}
// Output:
// η 3
// δΈ 3
// 1
// , 1
// o 1
// l 1
// l 1
// e 1
// H 1
}
func main() {
ExampleDecodeLastRune()
fmt.Println(utf8.RuneError, "a \n bπ")
s := "\\ \n \\"
fmt.Println(s[0], len(s), s)
}