Skip to content

buffer.toString() no longer accepts null as encoding #13936

Closed
@ibc

Description

@ibc
  • Version: v8.1.2
  • Platform: Darwin ibc-macbook 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
  • Subsystem:

According to the doc, buffer.toString([encoding[, start[, end]]]):

encoding The character encoding to decode to. Default: 'utf8'

In Node 4/5/6/7 this works:

buffer.toString(null, 0);
buffer.toString(undefined, 0);

However, in Node 8, null does not work and produces TypeError: Unknown encoding: null.

Example:

var buf = Buffer.from("hello", 'utf8');

buf.toString(null);
// => TypeError: Unknown encoding: null

Not sure why null is no longer considered "use the default value".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions