Skip to content

Commit 0a56e96

Browse files
Anton AndesenFishrock123
Anton Andesen
authored andcommitted
doc: add note for binary safe string reading
`readable.setEncoding(null)` - may be the most preferable way to proxy a binary data without any encoding/decoding overhead PR-URL: #5155 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 2b88523 commit 0a56e96

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/stream.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ potentially mangled if you simply pulled the Buffers directly and
416416
called [`buf.toString(encoding)`][] on them. If you want to read the data
417417
as strings, always use this method.
418418

419+
Also you can disable any encoding at all with `readable.setEncoding(null)`.
420+
This approach is very useful if you deal with binary data or with large
421+
multi-byte strings spread out over multiple chunks.
422+
419423
```js
420424
var readable = getReadableStreamSomehow();
421425
readable.setEncoding('utf8');

0 commit comments

Comments
 (0)