package main

import (
    "fmt"
    "unicode/utf8"
)

func main(){
    var str string
    str="asSASA ddd dsjkdsjs dk"
    fmt.Printf("String %s\nLength: %d, Runes: %d\n", str,
len([]byte(str)), utf8.RuneCount([]byte(str)))
}

输出结果:

$ go run firstthirdtwo.go
String asSASA ddd dsjkdsjs dk
Length: 22, Runes: 22

posted on 2016-01-11 08:58  王洪洪  阅读(713)  评论(0编辑  收藏  举报