File: example_test.go

package info (click to toggle)
golang-github-miekg-dns 0.0~git20161018.0.58f52c5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-backports
  • size: 1,020 kB
  • ctags: 1,596
  • sloc: makefile: 4
file content (18 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 -> الانترنت.اختبار
}