Skip to content

string_decoder and V8 decoder misaligned in edge case #22626

@addaleax

Description

@addaleax
  • 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.

Metadata

Metadata

Assignees

Labels

string_decoderIssues and PRs related to the string_decoder subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions