# Punycode.js API documentation






## `punycode`
* [`punycode`](#punycode)
* [`punycode.version`](#punycode.version)
* [`punycode.decode`](#punycode.decode)
* [`punycode.encode`](#punycode.encode)
* [`punycode.toASCII`](#punycode.toASCII)
* [`punycode.toUnicode`](#punycode.toUnicode)






## `punycode.ucs2`
* [`punycode.ucs2`](#punycode.ucs2)
* [`punycode.ucs2.decode`](#punycode.ucs2.decode)
* [`punycode.ucs2.encode`](#punycode.ucs2.encode)












## `punycode`

### `punycode`
*(Object)*: The `punycode` object.
[▲][1]

### `punycode.version`
*(String)*: A string representing the current Punycode.js version number.
[▲][1]

### `punycode.decode(input)`
Converts a Punycode string of ASCII code points to a string of Unicode code points.
[▲][1]

#### Arguments
1. `input` *(String)*: The Punycode string of ASCII code points.

#### Returns
*(String)*: The resulting string of Unicode code points.

### `punycode.encode(input)`
Converts a string of Unicode code points to a Punycode string of ASCII code points.
[▲][1]

#### Arguments
1. `input` *(String)*: The string of Unicode code points.

#### Returns
*(String)*: The resulting Punycode string of ASCII code points.

### `punycode.toASCII(domain)`
Converts a Unicode string representing a domain name to Punycode. Only the non-ASCII parts of the domain name will be converted, i.e. it doesn't matter if you call it with a domain that's already in ASCII.
[▲][1]

#### Arguments
1. `domain` *(String)*: The domain name to convert, as a Unicode string.

#### Returns
*(String)*: The Punycode representation of the given domain name.

### `punycode.toUnicode(domain)`
Converts a Punycode string representing a domain name to Unicode. Only the Punycoded parts of the domain name will be converted, i.e. it doesn't matter if you call it on a string that has already been converted to Unicode.
[▲][1]

#### Arguments
1. `domain` *(String)*: The Punycode domain name to convert to Unicode.

#### Returns
*(String)*: The Unicode representation of the given Punycode string.









## `punycode.ucs2`

### `punycode.ucs2`
*(Object)*: An object of methods to convert from JavaScript's internal character representation *(UCS-2)* to decimal Unicode code points, and back.
[▲][1]

### `punycode.ucs2.decode(string)`
Creates an array containing the decimal code points of each Unicode character in the string. While JavaScript uses UCS-2 internally, this function will convert a pair of surrogate halves *(each of which UCS-2 exposes as separate characters)* into a single code point, matching UTF-16.
[▲][1]

#### Arguments
1. `string` *(String)*: The Unicode input string *(UCS-2)*.

#### Returns
*(Array)*: The new array of code points.

### `punycode.ucs2.encode(codePoints)`
Creates a string based on an array of decimal code points.
[▲][1]

#### Arguments
1. `codePoints` *(Array)*: The array of decimal code points.

#### Returns
*(String)*: The new Unicode string *(UCS-2)*.










  [1]: #readme "Jump back to the TOC."