...
1
2
3
4
5 package idna_test
6
7 import (
8 "fmt"
9
10 "golang.org/x/net/idna"
11 )
12
13 func ExampleProfile() {
14
15 fmt.Println(idna.ToASCII(""))
16 fmt.Println(idna.ToASCII("*.GÖPHER.com"))
17 fmt.Println(idna.Punycode.ToASCII("*.GÖPHER.com"))
18
19
20 fmt.Println(idna.Lookup.ToASCII(""))
21 fmt.Println(idna.Lookup.ToASCII("www.GÖPHER.com"))
22
23
24
25 fmt.Println(idna.Registration.ToASCII("www.GÖPHER.com"))
26 fmt.Println(idna.Registration.ToASCII("www.göpher.com"))
27
28
29
30
31
32
33
34
35
36 }
37
38 func ExampleNew() {
39 var p *idna.Profile
40
41
42 p = idna.New()
43 fmt.Println(p.ToASCII("*.faß.com"))
44
45
46 p = idna.New(
47 idna.MapForLookup(),
48 idna.Transitional(true))
49 fmt.Println(p.ToASCII("*.faß.com"))
50
51
52 p = idna.New(idna.ValidateForRegistration())
53 fmt.Println(p.ToUnicode("*.faß.com"))
54
55
56 p = idna.New(
57 idna.MapForLookup(),
58 idna.Transitional(true),
59 idna.StrictDomainName(false))
60 fmt.Println(p.ToASCII("*.faß.com"))
61
62
63
64
65
66
67 }
68
View as plain text