SelectIDNA is a convenience function for encoding to/from Punycode. If ulabel is true, it returns U-label encoded domain in the Unicode NFC form. If ulabel is false, it returns A-label encoded domain.
(ulabel bool, domain string)
| 29 | // form. |
| 30 | // If ulabel is false, it returns A-label encoded domain. |
| 31 | func SelectIDNA(ulabel bool, domain string) (string, error) { |
| 32 | if ulabel { |
| 33 | uDomain, err := idna.ToUnicode(domain) |
| 34 | return norm.NFC.String(uDomain), err |
| 35 | } |
| 36 | return idna.ToASCII(domain) |
| 37 | } |