go []rune(chinese) 和utf8.RuneCountInString(chinese) 查询含中文的字符串长度
func main(){
var chinese = "我是中国人, I am Chinese"
fmt.Println("chinese length", len(chinese))
fmt.Println("chinese word length", len([]rune(chinese)))
fmt.Println("chinese word length", utf8.RuneCountInString(chinese))
}
输出:
chinese length 31
chinese word length 19
chinese word length 19
写入自己的博客中才能记得长久