Working with IDN domains and Punycode in JavaScript

You can utilize a well, documented, unit tested punycode.js library (which is also bundled with node.js and io.js).