mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
In this range variant "for k, v := range aString", k must be the byte position of the rune in the byte array, rather than the index of the rune in the rune array. Fixes #1088.
15 lines
275 B
Go
15 lines
275 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
for i, ch := range "日本語" {
|
|
fmt.Printf("%#U starts at byte position %d\n", ch, i)
|
|
}
|
|
}
|
|
|
|
// Output:
|
|
// U+65E5 '日' starts at byte position 0
|
|
// U+672C '本' starts at byte position 3
|
|
// U+8A9E '語' starts at byte position 6
|