const nihongo = "日本語" for i, v := range nihongo { fmt.Printf("%#U starts at byte position %d\n", v, i) } // 输出: // U+65E5 '日' starts at byte position 0 // U+672C '本' starts at byte position 3 // U+8A9E '語' starts at byte position 6
说明
To answer the question posed at the beginning: Strings are built from bytes so indexing them yields bytes, not characters. A string might not even hold characters. In fact, the definition of “character” is ambiguous and it would be a mistake to try to resolve the ambiguity by defining that strings are made of characters.