Convert any string to Unicode or ASCII, respecting the Zero Width Joiner (ZWJ) character. zwj-name-converter was especially designed to be fully compatible with the Handshake protocol but is not limited to that. The zwj-name-converter is currently implemented on https://niami.io/.
It is compatible with Unicode Version 14.0.
Via npm:
npm install zwj-name-converter
In Node.js:
const converter = require("zwj-name-converter");
// To Unicode
converter.nameToUnicode("xn--vi8h"); // 🍕
converter.nameToUnicode("xn--nn8hi4bz4d"); // 🧑🏼🚀
converter.nameToUnicode("👨🏾❤👨🏽"); // 👨🏾❤👨🏽
// Unsupported or Invalid Punycode will not be converted
converter.nameToUnicode("xn--0"); // xn--0
converter.nameToUnicode("xn--v86c5408p"); // xn--v86c5408p
converter.nameToUnicode("xn--1ug5408p"); // xn--1ug5408p
// To ASCII
converter.nameToAscii("🍕"); // xn--vi8h
converter.nameToAscii("&/#, +()$~%.AL IC E-bob"); // alice-bob
converter.nameToAscii("xn--vi8h文教材"); // xn--xn--vi8h-5x3qlog6n
npm test
zwj-name-converter is available under the MIT license.