Skip to content

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.

License

GPL-2.0, MIT licenses found

Licenses found

GPL-2.0
LICENSE-GPL.txt
MIT
LICENSE-MIT.txt
Notifications You must be signed in to change notification settings

macstens/punycode.js

 
 

Repository files navigation

Punycode.js

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.

This JavaScript library is the result of comparing, optimizing and documenting different open-source implementations of the Punycode algorithm:

This project is bundled with Node.js v0.6.2+.

Installation and usage

In a browser:

<script src="punycode.js"></script>

Via npm (only required for Node.js releases older than v0.6.2):

npm install punycode

In Narwhal, Node.js, and RingoJS:

var punycode = require('punycode');

In Rhino:

load('punycode.js');

Using an AMD loader like RequireJS:

require(
  {
    'paths': {
      'punycode': 'path/to/punycode'
    }
  },
  ['punycode'],
  function(punycode) {
    console.log(punycode);
  }
);

Usage example:

// encode/decode domain names
punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'

// encode/decode domain name parts
punycode.encode('mañana'); // 'maana-pta'
punycode.decode('maana-pta'); // 'mañana'
punycode.encode('☃-⌘'); // '--dqo34k'
punycode.decode('--dqo34k'); // '☃-⌘'

Full API documentation is available.

Cloning this repo

To clone this repository including all submodules, using Git 1.6.5 or later:

git clone --recursive https://github.com/bestiejs/punycode.js.git
cd punycode.js

For older Git versions, just use:

git clone https://github.com/bestiejs/punycode.js.git
cd punycode.js
git submodule update --init

Feel free to fork if you see possible improvements!

Authors

Contributors

License

Punycode.js is dual licensed under the MIT and GPL licenses.

About

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.

Resources

License

GPL-2.0, MIT licenses found

Licenses found

GPL-2.0
LICENSE-GPL.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Packages

No packages published