-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path03_read_byte_from_unicode.go
More file actions
40 lines (37 loc) · 958 Bytes
/
03_read_byte_from_unicode.go
File metadata and controls
40 lines (37 loc) · 958 Bytes
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
39
40
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Dvacátá druhá část
// Vstupně-výstupní funkce standardní knihovny programovacího jazyka Go
// https://www.root.cz/clanky/vstupne-vystupni-funkce-standardni-knihovny-programovaciho-jazyka-go/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů z dvacáté druhé části:
// https://github.com/tisnik/go-root/blob/master/article_22/README.md
//
// Demonstrační příklad číslo 3:
// Postupné načtení bajtů z řetězce, ukázka použití Unicode.
package main
import (
"fmt"
"io"
"strings"
)
func main() {
reader := strings.NewReader("* ěščř ½µ§я¤ *")
for {
b, err := reader.ReadByte()
if err == io.EOF {
fmt.Println("\nEOF detected")
break
}
if err == nil {
fmt.Printf("%02x ", b)
} else {
fmt.Printf("\nerror %v", err)
break
}
}
}