golang 计算字符串长度(包含汉字)
2018-08-20 本文已影响513人
千罹
package main
import (
"fmt"
"unicode/utf8"
)
func main() {
count := utf8.RuneCountInString("㕎檕獶栲")
fmt.Print(count) // 4
}
package main
import (
"fmt"
"unicode/utf8"
)
func main() {
count := utf8.RuneCountInString("㕎檕獶栲")
fmt.Print(count) // 4
}