Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const {
- TextEncoder,
- TextDecoder
- } = require('util');
- let original = 'this is some data';
- const encoder = new TextEncoder();
- const uint8array = encoder.encode(original);
- console.log('uint8array', uint8array);
- const decoder = new TextDecoder('utf-8');
- let string = '';
- string += decoder.decode(uint8array, {stream: true});
- string += decoder.decode();
- console.log('string', string);
Add Comment
Please, Sign In to add comment