Module basic module

Module punycode

punycode Internationalized Domain Name Conversion Module

Punycode is a character encoding scheme defined by RFC 3492 mainly used for internationalized domain names. Because the host name in the URL can only be ASCII characters, the host name including non-ASCII characters must be converted to ASCII using the punycode algorithm.

Instructions:

1
var punycode = require('punycode');

Static function

encode

Convert a Unicode string into an equivalent Punycode string containing only ASCII characters

1
static String punycode.encode(String domain);

Call parameters:

  • domain : String, given Unicode string

Return result:

  • String , returns the encoded Punycode string containing only ASCII characters

decode

Convert a Punycode string into an equivalent Unicode string

1
static String punycode.decode(String domain);

Call parameters:

  • domain : String, given Unicode string

Return result:

  • String , returns the decoded Unicode string

toASCII

Convert a Unicode string representing a domain name to a string containing only ASCII characters. Only the non-ASCII character strings that represent the part of the domain name will be converted. In other words, if you call a string that has been converted to ASCII, there is no problem.

1
static String punycode.toASCII(String domain);

Call parameters:

  • domain : String, given Unicode string

Return result:

  • String , returns the encoded ASCII string

toUnicode

Convert a Punycode string representing a domain name to a Unicode string. Only the Punycode string representing the part of the domain name will be converted. In other words, if you call a string that has been converted to Unicode, there is no problem.

1
static String punycode.toUnicode(String domain);

Call parameters:

  • domain : String, given ASCII string

Return result:

  • String , returns the decoded Unicode string