example_test.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package runenames_test
  5. import (
  6. "fmt"
  7. "golang.org/x/text/unicode/runenames"
  8. )
  9. func Example() {
  10. runes := []rune{
  11. -1,
  12. '\U00000000',
  13. '\U0000001f',
  14. '\U00000020',
  15. '\U00000021',
  16. '\U00000041',
  17. '\U0000007e',
  18. '\U0000007f',
  19. '\U00000080',
  20. '\U000000e0',
  21. '\U0000037f',
  22. '\U00000380',
  23. '\U00000381',
  24. '\U00000382',
  25. '\U00000383',
  26. '\U00000384',
  27. '\U00000385',
  28. '\U00000386',
  29. '\U000007c0',
  30. '\U00002603',
  31. '\U000033ff',
  32. '\U00003400',
  33. '\U00003401',
  34. '\U00003402',
  35. '\U00004dc0',
  36. '\U00009fd5',
  37. '\U00009fff',
  38. '\U0000a000',
  39. 0xdc00, // '\U0000dc00' (Low Surrogate) is an invalid Go literal.
  40. '\U0000f800',
  41. '\U0000fffc',
  42. '\U0000fffd',
  43. '\U0000fffe',
  44. '\U0000ffff',
  45. '\U00010000',
  46. '\U0001f574',
  47. '\U0002fa1d',
  48. '\U0002fa1e',
  49. '\U000e0100',
  50. '\U000e01ef',
  51. '\U000e01f0',
  52. '\U00100000',
  53. '\U0010fffd',
  54. '\U0010fffe',
  55. '\U0010ffff',
  56. }
  57. for _, r := range runes {
  58. fmt.Printf("%08x %q\n", r, runenames.Name(r))
  59. }
  60. // Output:
  61. // -0000001 ""
  62. // 00000000 "<control>"
  63. // 0000001f "<control>"
  64. // 00000020 "SPACE"
  65. // 00000021 "EXCLAMATION MARK"
  66. // 00000041 "LATIN CAPITAL LETTER A"
  67. // 0000007e "TILDE"
  68. // 0000007f "<control>"
  69. // 00000080 "<control>"
  70. // 000000e0 "LATIN SMALL LETTER A WITH GRAVE"
  71. // 0000037f "GREEK CAPITAL LETTER YOT"
  72. // 00000380 ""
  73. // 00000381 ""
  74. // 00000382 ""
  75. // 00000383 ""
  76. // 00000384 "GREEK TONOS"
  77. // 00000385 "GREEK DIALYTIKA TONOS"
  78. // 00000386 "GREEK CAPITAL LETTER ALPHA WITH TONOS"
  79. // 000007c0 "NKO DIGIT ZERO"
  80. // 00002603 "SNOWMAN"
  81. // 000033ff "SQUARE GAL"
  82. // 00003400 "<CJK Ideograph Extension A>"
  83. // 00003401 "<CJK Ideograph Extension A>"
  84. // 00003402 "<CJK Ideograph Extension A>"
  85. // 00004dc0 "HEXAGRAM FOR THE CREATIVE HEAVEN"
  86. // 00009fd5 "<CJK Ideograph>"
  87. // 00009fff ""
  88. // 0000a000 "YI SYLLABLE IT"
  89. // 0000dc00 "<Low Surrogate>"
  90. // 0000f800 "<Private Use>"
  91. // 0000fffc "OBJECT REPLACEMENT CHARACTER"
  92. // 0000fffd "REPLACEMENT CHARACTER"
  93. // 0000fffe ""
  94. // 0000ffff ""
  95. // 00010000 "LINEAR B SYLLABLE B008 A"
  96. // 0001f574 "MAN IN BUSINESS SUIT LEVITATING"
  97. // 0002fa1d "CJK COMPATIBILITY IDEOGRAPH-2FA1D"
  98. // 0002fa1e ""
  99. // 000e0100 "VARIATION SELECTOR-17"
  100. // 000e01ef "VARIATION SELECTOR-256"
  101. // 000e01f0 ""
  102. // 00100000 "<Plane 16 Private Use>"
  103. // 0010fffd "<Plane 16 Private Use>"
  104. // 0010fffe ""
  105. // 0010ffff ""
  106. }