Skip to content

Instantly share code, notes, and snippets.

@huawww
Last active December 20, 2016 08:30
Show Gist options
  • Save huawww/ea1de878649f2031fdde76eb4b8bff3f to your computer and use it in GitHub Desktop.
Save huawww/ea1de878649f2031fdde76eb4b8bff3f to your computer and use it in GitHub Desktop.
ascii2str
//nodejs v6.4.0
console.log("Hello, World!");
var s = 's';
var charCode = s.charCodeAt(0);
console.log(charCode);
var buf = Buffer.from([charCode], 'ascii');
console.log(buf.toString());
var y = '2122234041424344457B7C7D7E7F';
var bufHex = Buffer.allocUnsafe(0);
bufHex = Buffer.concat([bufHex, Buffer.from(y, 'hex')]);
console.log(bufHex, bufHex.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment