package idn

import "k8s.io/kubernetes/Godeps/_workspace/src/github.com/miekg/dns/idn"

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

Index

Examples

Functions

func FromPunycode

func FromPunycode(s string) string

FromPunycode returns unicode domain name from provided punycode string.

Example

Code:play 

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 incorrect result for strings for non-canonical unicode strings.

Example

Code:play 

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

Source Files

punycode.go

Version
v0.14.0
Published
Mar 30, 2015
Platform
linux/amd64
Imports
4 packages
Last checked
8 minutes ago

Tools for package owners.