A robust Punycode converter that fully complies to \href{https://tools.ietf.org/html/rfc3492}{\texttt{ RFC 3492}} and \href{https://tools.ietf.org/html/rfc5891}{\texttt{ RFC 5891}}, and works on nearly all Java\+Script platforms.

This Java\+Script library is the result of comparing, optimizing and documenting different open-\/source implementations of the Punycode algorithm\+:


\begin{DoxyItemize}
\item \href{https://tools.ietf.org/html/rfc3492\#appendix-C}{\texttt{ The C example code from RFC 3492}}
\item \href{http://opensource.apple.com/source/ICU/ICU-400.42/icuSources/common/punycode.c}{\texttt{ {\ttfamily punycode.\+c} by {\itshape Markus W. Scherer} (IBM)}}
\item \href{https://github.com/bnoordhuis/punycode/blob/master/punycode.c}{\texttt{ {\ttfamily punycode.\+c} by {\itshape Ben Noordhuis}}}
\item \href{http://stackoverflow.com/questions/183485/can-anyone-recommend-a-good-free-javascript-for-punycode-to-unicode-conversion/301287\#301287}{\texttt{ Java\+Script implementation by {\itshape some}}}
\item \href{https://github.com/joyent/node/blob/426298c8c1c0d5b5224ac3658c41e7c2a3fe9377/lib/punycode.js}{\texttt{ {\ttfamily punycode.\+js} by {\itshape Ben Noordhuis}}} (note\+: \href{https://github.com/joyent/node/issues/2072}{\texttt{ not fully compliant}})
\end{DoxyItemize}

This project is \href{https://github.com/joyent/node/blob/master/lib/punycode.js}{\texttt{ bundled}} with \href{https://github.com/joyent/node/compare/975f1930b1...61e796decc}{\texttt{ Node.\+js v0.\+6.\+2+}} and \href{https://github.com/iojs/io.js/blob/v1.x/lib/punycode.js}{\texttt{ io.\+js v1.\+0.\+0+}}.\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18256}{}\doxysection{Installation}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18256}
Via \href{https://www.npmjs.com/}{\texttt{ npm}} (only required for Node.\+js releases older than v0.\+6.\+2)\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install punycode }

\end{DoxyCode}


Via \href{http://bower.io/}{\texttt{ Bower}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{bower install punycode }

\end{DoxyCode}


Via \href{https://github.com/component/component}{\texttt{ Component}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{component install bestiejs/punycode.js }

\end{DoxyCode}


In a browser\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}punycode.js"{}></script> }

\end{DoxyCode}


In \href{https://nodejs.org/}{\texttt{ Node.\+js}}, \href{https://iojs.org/}{\texttt{ io.\+js}}, \href{http://narwhaljs.org/}{\texttt{ Narwhal}}, and \href{http://ringojs.org/}{\texttt{ Ringo\+JS}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var punycode = require('punycode'); }

\end{DoxyCode}


In \href{http://www.mozilla.org/rhino/}{\texttt{ Rhino}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{load('punycode.js'); }

\end{DoxyCode}


Using an AMD loader like \href{http://requirejs.org/}{\texttt{ Require\+JS}}\+:


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

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18257}{}\doxysection{API}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18257}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18258}{}\doxysubsection{$<$tt$>$punycode.\+decode(string)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18258}
Converts a Punycode string of ASCII symbols to a string of Unicode symbols.


\begin{DoxyCode}{0}
\DoxyCodeLine{// decode domain name parts}
\DoxyCodeLine{punycode.decode('maana-\/pta'); // 'mañana'}
\DoxyCodeLine{punycode.decode('-\/-\/dqo34k'); // '☃-\/⌘' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18259}{}\doxysubsection{$<$tt$>$punycode.\+encode(string)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18259}
Converts a string of Unicode symbols to a Punycode string of ASCII symbols.


\begin{DoxyCode}{0}
\DoxyCodeLine{// encode domain name parts}
\DoxyCodeLine{punycode.encode('mañana'); // 'maana-\/pta'}
\DoxyCodeLine{punycode.encode('☃-\/⌘'); // '-\/-\/dqo34k' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18260}{}\doxysubsection{$<$tt$>$punycode.\+to\+Unicode(input)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18260}
Converts a Punycode string representing a domain name or an email address to Unicode. Only the Punycoded parts of the input will be converted, i.\+e. it doesn’t matter if you call it on a string that has already been converted to Unicode.


\begin{DoxyCode}{0}
\DoxyCodeLine{// decode domain names}
\DoxyCodeLine{punycode.toUnicode('xn-\/-\/maana-\/pta.com');}
\DoxyCodeLine{// → 'mañana.com'}
\DoxyCodeLine{punycode.toUnicode('xn-\/-\/-\/-\/dqo34k.com');}
\DoxyCodeLine{// → '☃-\/⌘.com'}
\DoxyCodeLine{}
\DoxyCodeLine{// decode email addresses}
\DoxyCodeLine{punycode.toUnicode('джумла@xn-\/-\/p-\/8sbkgc5ag7bhce.xn-\/-\/ba-\/lmcq');}
\DoxyCodeLine{// → 'джумла@джpумлатест.bрфa' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18261}{}\doxysubsection{$<$tt$>$punycode.\+to\+ASCII(input)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18261}
Converts a lowercased Unicode string representing a domain name or an email address to Punycode. Only the non-\/\+ASCII parts of the input will be converted, i.\+e. it doesn’t matter if you call it with a domain that’s already in ASCII.


\begin{DoxyCode}{0}
\DoxyCodeLine{// encode domain names}
\DoxyCodeLine{punycode.toASCII('mañana.com');}
\DoxyCodeLine{// → 'xn-\/-\/maana-\/pta.com'}
\DoxyCodeLine{punycode.toASCII('☃-\/⌘.com');}
\DoxyCodeLine{// → 'xn-\/-\/-\/-\/dqo34k.com'}
\DoxyCodeLine{}
\DoxyCodeLine{// encode email addresses}
\DoxyCodeLine{punycode.toASCII('джумла@джpумлатест.bрфa');}
\DoxyCodeLine{// → 'джумла@xn-\/-\/p-\/8sbkgc5ag7bhce.xn-\/-\/ba-\/lmcq' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18262}{}\doxysubsection{$<$tt$>$punycode.\+ucs2$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18262}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18263}{}\doxysubsubsection{$<$tt$>$punycode.\+ucs2.\+decode(string)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18263}
Creates an array containing the numeric code point values of each Unicode symbol in the string. While \href{https://mathiasbynens.be/notes/javascript-encoding}{\texttt{ Java\+Script 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.


\begin{DoxyCode}{0}
\DoxyCodeLine{punycode.ucs2.decode('abc');}
\DoxyCodeLine{// → [0x61, 0x62, 0x63]}
\DoxyCodeLine{// surrogate pair for U+1D306 TETRAGRAM FOR CENTRE:}
\DoxyCodeLine{punycode.ucs2.decode('\(\backslash\)uD834\(\backslash\)uDF06');}
\DoxyCodeLine{// → [0x1D306] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18264}{}\doxysubsubsection{$<$tt$>$punycode.\+ucs2.\+encode(code\+Points)$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18264}
Creates a string based on an array of numeric code point values.


\begin{DoxyCode}{0}
\DoxyCodeLine{punycode.ucs2.encode([0x61, 0x62, 0x63]);}
\DoxyCodeLine{// → 'abc'}
\DoxyCodeLine{punycode.ucs2.encode([0x1D306]);}
\DoxyCodeLine{// → '\(\backslash\)uD834\(\backslash\)uDF06' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18265}{}\doxysubsection{$<$tt$>$punycode.\+version$<$/tt$>$}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18265}
A string representing the current Punycode.\+js version number.\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18266}{}\doxysection{Unit tests \& code coverage}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18266}
After cloning this repository, run {\ttfamily npm install -\/-\/dev} to install the dependencies needed for Punycode.\+js development and testing. You may want to install Istanbul {\itshape globally} using {\ttfamily npm install istanbul -\/g}.

Once that’s done, you can run the unit tests in Node using {\ttfamily npm test} or {\ttfamily node tests/tests.\+js}. To run the tests in Rhino, Ringo, Narwhal, Phantom\+JS, and web browsers as well, use {\ttfamily grunt test}.

To generate the code coverage report, use {\ttfamily grunt cover}.

Feel free to fork if you see possible improvements!\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18267}{}\doxysection{Author}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18267}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{1}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ \href{https://twitter.com/mathias}{\texttt{ }}    }\\\cline{1-1}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ \href{https://twitter.com/mathias}{\texttt{ }}    }\\\cline{1-1}
\endhead
\href{https://mathiasbynens.be/}{\texttt{ Mathias Bynens}}   \\\cline{1-1}
\end{longtabu}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18268}{}\doxysection{Contributors}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18268}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{1}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ \href{https://twitter.com/jdalton}{\texttt{ }}    }\\\cline{1-1}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ \href{https://twitter.com/jdalton}{\texttt{ }}    }\\\cline{1-1}
\endhead
\href{http://allyoucanleet.com/}{\texttt{ John-\/\+David Dalton}}   \\\cline{1-1}
\end{longtabu}
\hypertarget{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18269}{}\doxysection{License}\label{md_sfcode_node_modules_node_libs_browser_node_modules_punycode_README_autotoc_md18269}
Punycode.\+js is available under the \href{https://mths.be/mit}{\texttt{ MIT}} license. 