咖啡伴侣

呆在上海
posts - 163, comments - 156, trackbacks - 0, articles - 2

golang string rune len 可能不同

Posted on 2013-08-19 11:31 oathleo 阅读(2745) 评论(0)  编辑  收藏 所属分类: Golang
        rune_str := []rune(info)
        fmt.Print("rune_len:" , len(rune_str))
        fmt.Print("string_len:" , len(info))

string 和对应的 rune数组的len不一定相同

如果info是有中文的,则两个length是不一样的,做string处理的时候,要注意

只有注册用户登录后才能发表评论。


网站导航: