unibabel.js/examples/node-thirty-two.js

9 lines
353 B
JavaScript
Raw Normal View History

2015-10-22 22:13:46 +00:00
var base32 = require('thirty-two');
var str = "I ½ ♥ 𩶘";
var buf = new Buffer(str, 'utf8');
console.log('charLen', 7);
console.log('byteLen', buf.byteLength, JSON.stringify(buf.toString('utf8')));
var b32 = base32.encode(buf); // to base32
console.log('encoded', b32.toString('utf8'));
console.log('decoded', base32.decode(b32).toString('utf8'));