Added examples for Punycode lib. Makes godoc look pretty.

This commit is contained in:
Alex Sergeyev 2014-09-18 09:58:55 -04:00
parent 7f7df57ce4
commit d353d0190a
1 changed files with 18 additions and 0 deletions

18
idn/example_test.go Normal file
View File

@ -0,0 +1,18 @@
package idn_test
import (
"fmt"
"github.com/miekg/dns/idn"
)
func ExampleToPunycode() {
name := "インターネット.テスト"
fmt.Printf("%s -> %s", name, idn.ToPunycode(name))
// Output: インターネット.テスト -> xn--eckucmux0ukc.xn--zckzah
}
func ExampleFromPunycode() {
name := "xn--mgbaja8a1hpac.xn--mgbachtv"
fmt.Printf("%s -> %s", name, idn.FromPunycode(name))
// Output: xn--mgbaja8a1hpac.xn--mgbachtv -> الانترنت.اختبار
}