1 // Copyright 2015 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.
12 // Functions starting with "Is" can be used to inspect which table of range a
13 // rune belongs to. Note that runes may fit into more than one range.
16 // constant with mixed type runes
17 const mixed
= "\b5Ὂg̀9! ℃ᾭG"
18 for _
, c
:= range mixed
{
19 fmt
.Printf("For %q:\n", c
)
20 if unicode
.IsControl(c
) {
21 fmt
.Println("\tis control rune")
23 if unicode
.IsDigit(c
) {
24 fmt
.Println("\tis digit rune")
26 if unicode
.IsGraphic(c
) {
27 fmt
.Println("\tis graphic rune")
29 if unicode
.IsLetter(c
) {
30 fmt
.Println("\tis letter rune")
32 if unicode
.IsLower(c
) {
33 fmt
.Println("\tis lower case rune")
35 if unicode
.IsMark(c
) {
36 fmt
.Println("\tis mark rune")
38 if unicode
.IsNumber(c
) {
39 fmt
.Println("\tis number rune")
41 if unicode
.IsPrint(c
) {
42 fmt
.Println("\tis printable rune")
44 if !unicode
.IsPrint(c
) {
45 fmt
.Println("\tis not printable rune")
47 if unicode
.IsPunct(c
) {
48 fmt
.Println("\tis punct rune")
50 if unicode
.IsSpace(c
) {
51 fmt
.Println("\tis space rune")
53 if unicode
.IsSymbol(c
) {
54 fmt
.Println("\tis symbol rune")
56 if unicode
.IsTitle(c
) {
57 fmt
.Println("\tis title case rune")
59 if unicode
.IsUpper(c
) {
60 fmt
.Println("\tis upper case rune")
67 // is not printable rune
108 // is title case rune
113 // is upper case rune
116 func ExampleSimpleFold() {
117 fmt
.Printf("%#U\n", unicode
.SimpleFold('A')) // 'a'
118 fmt
.Printf("%#U\n", unicode
.SimpleFold('a')) // 'A'
119 fmt
.Printf("%#U\n", unicode
.SimpleFold('K')) // 'k'
120 fmt
.Printf("%#U\n", unicode
.SimpleFold('k')) // '\u212A' (Kelvin symbol, K)
121 fmt
.Printf("%#U\n", unicode
.SimpleFold('\u212A')) // 'K'
122 fmt
.Printf("%#U\n", unicode
.SimpleFold('1')) // '1'
135 fmt
.Printf("%#U\n", unicode
.To(unicode
.UpperCase
, lcG
))
136 fmt
.Printf("%#U\n", unicode
.To(unicode
.LowerCase
, lcG
))
137 fmt
.Printf("%#U\n", unicode
.To(unicode
.TitleCase
, lcG
))
140 fmt
.Printf("%#U\n", unicode
.To(unicode
.UpperCase
, ucG
))
141 fmt
.Printf("%#U\n", unicode
.To(unicode
.LowerCase
, ucG
))
142 fmt
.Printf("%#U\n", unicode
.To(unicode
.TitleCase
, ucG
))
153 func ExampleToLower() {
155 fmt
.Printf("%#U\n", unicode
.ToLower(ucG
))
160 func ExampleToTitle() {
162 fmt
.Printf("%#U\n", unicode
.ToTitle(ucG
))
168 func ExampleToUpper() {
170 fmt
.Printf("%#U\n", unicode
.ToUpper(ucG
))
176 func ExampleSpecialCase() {
177 t
:= unicode
.TurkishCase
180 fmt
.Printf("%#U\n", t
.ToLower(lci
))
181 fmt
.Printf("%#U\n", t
.ToTitle(lci
))
182 fmt
.Printf("%#U\n", t
.ToUpper(lci
))
185 fmt
.Printf("%#U\n", t
.ToLower(uci
))
186 fmt
.Printf("%#U\n", t
.ToTitle(uci
))
187 fmt
.Printf("%#U\n", t
.ToUpper(uci
))