1 // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
3 // Copyright 2017 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
12 "golang.org/x/net/idna"
15 func ExampleProfile() {
16 // Raw Punycode has no restrictions and does no mappings.
17 fmt.Println(idna.ToASCII(""))
18 fmt.Println(idna.ToASCII("*.faß.com"))
19 fmt.Println(idna.Punycode.ToASCII("*.faß.com"))
21 // Rewrite IDN for lookup. This (currently) uses transitional mappings to
22 // find a balance between IDNA2003 and IDNA2008 compatibility.
23 fmt.Println(idna.Lookup.ToASCII(""))
24 fmt.Println(idna.Lookup.ToASCII("www.faß.com"))
26 // Convert an IDN to ASCII for registration purposes. This changes the
27 // encoding, but reports an error if the input was illformed.
28 fmt.Println(idna.Registration.ToASCII(""))
29 fmt.Println(idna.Registration.ToASCII("www.faß.com"))
33 // *.xn--fa-hia.com <nil>
34 // *.xn--fa-hia.com <nil>
37 // idna: invalid label ""
38 // www.xn--fa-hia.com <nil>
44 // Raw Punycode has no restrictions and does no mappings.
46 fmt.Println(p.ToASCII("*.faß.com"))
48 // Do mappings. Note that star is not allowed in a DNS lookup.
51 idna.Transitional(true)) // Map ß -> ss
52 fmt.Println(p.ToASCII("*.faß.com"))
54 // Lookup for registration. Also does not allow '*'.
55 p = idna.New(idna.ValidateForRegistration())
56 fmt.Println(p.ToUnicode("*.faß.com"))
58 // Set up a profile maps for lookup, but allows wild cards.
61 idna.Transitional(true), // Map ß -> ss
62 idna.StrictDomainName(false)) // Set more permissive ASCII rules.
63 fmt.Println(p.ToASCII("*.faß.com"))
66 // *.xn--fa-hia.com <nil>
67 // *.fass.com idna: disallowed rune U+002A
68 // *.faß.com idna: disallowed rune U+002A