string_test.go 346 B

12345678910111213141516171819
  1. package string_test
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestAll(t *testing.T) {
  7. s := string([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0})
  8. fmt.Println("'" + s + "'")
  9. fmt.Println([]byte(s))
  10. fmt.Println(len(s))
  11. s = "中文abc"
  12. fmt.Println("'" + s + "'")
  13. fmt.Println([]byte(s))
  14. fmt.Println(len(s))
  15. fmt.Println([]rune(s))
  16. fmt.Println(len([]rune(s)))
  17. }