8000 adds note to file · Abhicodeitout/GolangTraining@9517336 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9517336

Browse files
committed
adds note to file
1 parent 50a5aa8 commit 9517336

File tree

1 file changed

+20
-1
lines changed
  • 10_for-loop/07_rune-loop_UTF8/01

1 file changed

+20
-1
lines changed

10_for-loop/07_rune-loop_UTF8/01/main.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,29 @@ package main
33
import "fmt"
44

55
func main() {
6-
for i := 50; i <= 140; i++ {
6+
for i := 250; i <= 340; i++ {
77
fmt.Println(i, " - ", string(i), " - ", []byte(string(i)))
88
}
99
foo := "a"
1010
fmt.Println(foo)
1111
fmt.Printf("%T \n", foo)
1212
}
13+
14+
/*
15+
NOTE:
16+
Some operating systems (Windows) might not print characters where i < 256
17+
18+
If you have this issue, you can use this code:
19+
20+
fmt.Println(i, " - ", string(i), " - ", []int32(string(i)))
21+
22+
UTF-8 is the text coding scheme used by Go.
23+
24+
UTF-8 works with 1 - 4 bytes.
25+
26+
A byte is 8 bits.
27+
28+
[]byte deals with bytes, that is, only 1 byte (8 bits) at a time.
29+
30+
[]int32 allows us to store the value of 4 bytes, that is, 4 bytes * 8 bits per byte = 32 bits.
31+
*/

0 commit comments

Comments
 (0)
0