java字符串长度

java字符串是Unicode字符集,UTF-16编码

String str="hello你好";
Log.d(TAG,"str.length:"+str.length());//  7

golang 字符串长度

golang 字符串是utf8编码

package main

import (
    "fmt"
    "unicode/utf8"
)

func main() {
    count := utf8.RuneCountInString("hello你好")
    fmt.Print(count) // 7
}