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: https://github.com/nodejs/node/pull/5155
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
Anton Andesen authored and Jeremiah Senkpiel committed 2016-03-02 13:19:56 -05:00
1 parent 2b88523836
commit 0a56e9690b
1 file changed
+4
+4
View File
@@ -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');