blog.golang.org/strings1、const nihongo = "日本語" for index, runeValue := range nihongo { fmt.Printf("%#U starts at byte position %d\n", runeValue, index) }2、
const nihongo = "日本語"for i, w := 0, 0; i < len(nihonggo); i+=w { runeValue, width := utf8.DecodeRuneInString(nihonggo[i:]) fmt.Printf("%#U starts at byte position %d\n", runeValue, i) w = width}
有疑问加站长微信联系(非本文作者)
