Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
doc: document fs.createReadStream() encodings
Fixes #2700.
  • Loading branch information
Zachary Scott authored and bnoordhuis committed Mar 25, 2012
1 parent 83aae35 commit 0dd8e01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/fs.markdown
Expand Up @@ -586,7 +586,7 @@ Returns a new ReadStream object (See `Readable Stream`).

`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
start at 0.
start at 0. The `encoding` can be `'utf8'`, `'ascii'`, or `'base64'`.

An example to read the last 10 bytes of a file which is 100 bytes long:

Expand Down

3 comments on commit 0dd8e01

@mscdex
Copy link

@mscdex mscdex commented on 0dd8e01 Mar 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought encoding-wise you could use anything that buffer.toString() supports, since fs.ReadStream uses StringDecoder which uses buffer.toString() (for non-utf8 encoding).

@bnoordhuis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true. hex and ucs2 are valid encodings too. I'll update the commit. I think we eventually need a kind of primer on string encodings that we can link to.

@zzak
Copy link

@zzak zzak commented on 0dd8e01 Mar 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point that I never really considered.

The Buffer docs have a good intro to the different string encodings, but a more thorough doc might be helpful.

Please sign in to comment.