-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding clarity to buffer toString docs. #8984
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1811,8 +1811,8 @@ added: v0.1.90 | |
--> | ||
|
||
* `encoding` {String} The character encoding to decode to. **Default:** `'utf8'` | ||
* `start` {Integer} Where to start decoding. **Default:** `0` | ||
* `end` {Integer} Where to stop decoding (not inclusive). **Default:** [`buf.length`] | ||
* `start` {Integer} They byte offset to start decoding at. **Default:** `0` | ||
* `end` {Integer} The byte offset to stop decoding at (not inclusive). **Default:** [`buf.length`] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: long line |
||
* Return: {String} | ||
|
||
Decodes `buf` to a string according to the specified character encoding in `encoding`. | ||
|
@@ -1837,11 +1837,14 @@ console.log(buf.toString('ascii', 0, 5)); | |
|
||
const buf2 = Buffer.from('tést'); | ||
|
||
// Prints: tés | ||
console.log(buf.toString('utf8', 0, 3)); | ||
// Prints: 74c3a97374 | ||
console.log(buf2.toString('hex')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this isn’t mentioned in #8971, but the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, totally missed that. Sure. |
||
|
||
// Prints: tés | ||
console.log(buf.toString(undefined, 0, 3)); | ||
// Prints: té | ||
console.log(buf2.toString('utf8', 0, 3)); | ||
|
||
// Prints: té | ||
console.log(buf2.toString(undefined, 0, 3)); | ||
``` | ||
|
||
### buf.toJSON() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: They
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly me. Resolved!