package string_test import ( "fmt" "testing" ) func TestAll(t *testing.T) { s := string([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0}) fmt.Println("'" + s + "'") fmt.Println([]byte(s)) fmt.Println(len(s)) s = "中文abc" fmt.Println("'" + s + "'") fmt.Println([]byte(s)) fmt.Println(len(s)) fmt.Println([]rune(s)) fmt.Println(len([]rune(s))) }