golang中计算string长度用len函数,但是len函数返回的是字符串的 byte 数量
如果要得到字符串的字符数,可使用 "unicode/utf8" 包中的 RuneCountInString(str string) (n int)
因为string中不一定都是ASCII
golang中计算string长度用len函数,但是len函数返回的是字符串的 byte 数量
如果要得到字符串的字符数,可使用 "unicode/utf8" 包中的 RuneCountInString(str string) (n int)
因为string中不一定都是ASCII