Skip to content

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

License

Notifications You must be signed in to change notification settings

bnoordhuis/punycode.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

Installation and usage

In a browser:

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

In Node.js:

var Punycode = require('punycode');

In Narwhal and RingoJS:

var Punycode = require('punycode').Punycode;

In Rhino:

load('punycode.js');

In RequireJS:

require(['path/to/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'); // '☃-⌘'

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.7%
  • PHP 3.3%