- Version: 8 and above (but fixing might be semver-major)
- Subsystem: string_decoder
'use strict';
const { StringDecoder } = require('string_decoder');
const bufs = [
Buffer.from('f6', 'hex'),
Buffer.from('9b', 'hex'),
Buffer.from('d1', 'hex')
];
const sd = new StringDecoder('utf8');
let str = '';
for (const buf of bufs)
str += sd.write(buf);
str += sd.end();
console.log(`str = ${str}`) // 2 replacement chars
console.log(`orig = ${Buffer.concat(bufs).toString()}`) // 3 replacement chars
Haven’t really looked into this yet, so anybody who’d like to can feel free to do so.
Haven’t really looked into this yet, so anybody who’d like to can feel free to do so.