Mohamed Elsherif

17%
Flag icon
On the other hand, if we really care about the individual Unicode characters, we have to use other mechanisms. Consider the string from our very first example, which includes two East Asian characters. Figure 3.5 illustrates its representation in memory. The string contains 13 bytes, but interpreted as UTF-8, it encodes only nine code points or runes: Figure 3.5. A range loop decodes a UTF-8-encoded string. Click here to view code image import "unicode/utf8" s := "Hello, " fmt.Println(len(s))                    // "13" fmt.Println(utf8.RuneCountInString(s)) // "9" To process those characters, ...more
The Go Programming Language
Rate this book
Clear rating
Open Preview