idn

package
v0.0.0-...-bfdd474 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2015 License: BSD-3-Clause, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package idn implements encoding from and to punycode as speficied by RFC 3492.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromPunycode

func FromPunycode(s string) string

FromPunycode returns unicode domain name from provided punycode string.

Example
package main

import (
	"fmt"
	"github.com/miekg/dns/idn"
)

func main() {
	name := "xn--mgbaja8a1hpac.xn--mgbachtv"
	fmt.Printf("%s -> %s", name, idn.FromPunycode(name))
}
Output:

xn--mgbaja8a1hpac.xn--mgbachtv -> الانترنت.اختبار

func ToPunycode

func ToPunycode(s string) string

ToPunycode converts unicode domain names to DNS-appropriate punycode names. This function would return an empty string result for domain names with invalid unicode strings. This function expects domain names in lowercase.

Example
package main

import (
	"fmt"
	"github.com/miekg/dns/idn"
)

func main() {
	name := "インターネット.テスト"
	fmt.Printf("%s -> %s", name, idn.ToPunycode(name))
}
Output:

インターネット.テスト -> xn--eckucmux0ukc.xn--zckzah

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL