Skip to content

Commit

Permalink
doc: add note for binary safe string reading
Browse files Browse the repository at this point in the history
`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 <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
  • Loading branch information
Anton Andesen authored and Fishrock123 committed Mar 2, 2016
1 parent 2b88523 commit 0a56e96
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api/stream.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ potentially mangled if you simply pulled the Buffers directly and
called [`buf.toString(encoding)`][] on them. If you want to read the data
as strings, always use this method.

Also you can disable any encoding at all with `readable.setEncoding(null)`.
This approach is very useful if you deal with binary data or with large
multi-byte strings spread out over multiple chunks.

```js
var readable = getReadableStreamSomehow();
readable.setEncoding('utf8');
Expand Down

0 comments on commit 0a56e96

Please sign in to comment.