Skip to content

Instantly share code, notes, and snippets.

@creationix
Last active March 31, 2020 07:15
Show Gist options
  • Save creationix/9024507 to your computer and use it in GitHub Desktop.
Save creationix/9024507 to your computer and use it in GitHub Desktop.
Convert a hex string (base-16) to a base-65536 (16-bit) string.
function hexToBase65536(hex) {
var result = "";
for (var i = hex.length ; i > 0; i -= 4) {
result += String.fromCharCode(parseInt(hex.substring(i - 4, i), 16));
}
return result;
}
@creationix
Copy link
Author

hexToBase65536("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3")
//-> "믓頯펑ࡳ᱌鮦첱迥ꥊ"

@roflmoqkz
Copy link

hexToBase65536("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment