| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1809,12 +1809,13 @@ added: v0.1.90 | |||
| 1809 | 1809 | --> | |
| 1810 | 1810 | ||
| 1811 | 1811 | * `encoding` {String} The character encoding to decode to. **Default:** `'utf8'` | |
| 1812 | - * `start` {Integer} Where to start decoding. **Default:** `0` | ||
| 1813 | - * `end` {Integer} Where to stop decoding (not inclusive). **Default:** [`buf.length`] | ||
| 1812 | + * `start` {Integer} The byte offset to start decoding at. **Default:** `0` | ||
| 1813 | + * `end` {Integer} The byte offset to stop decoding at (not inclusive). | ||
| 1814 | + **Default:** [`buf.length`] | ||
| 1814 | 1815 | * Return: {String} | |
| 1815 | 1816 | ||
| 1816 | - Decodes `buf` to a string according to the specified character encoding in `encoding`. | ||
| 1817 | - `start` and `end` may be passed to decode only a subset of `buf`. | ||
| 1817 | + Decodes `buf` to a string according to the specified character encoding in | ||
| 1818 | + `encoding`. `start` and `end` may be passed to decode only a subset of `buf`. | ||
| 1818 | 1819 | ||
| 1819 | 1820 | Examples: | |
| 1820 | 1821 | ||
@@ -1827,19 +1828,22 @@ for (var i = 0 ; i < 26 ; i++) { | |||
| 1827 | 1828 | } | |
| 1828 | 1829 | ||
| 1829 | 1830 | // Prints: abcdefghijklmnopqrstuvwxyz | |
| 1830 | - console.log(buf.toString('ascii')); | ||
| 1831 | + console.log(buf1.toString('ascii')); | ||
| 1831 | 1832 | ||
| 1832 | 1833 | // Prints: abcde | |
| 1833 | - console.log(buf.toString('ascii', 0, 5)); | ||
| 1834 | + console.log(buf1.toString('ascii', 0, 5)); | ||
| 1834 | 1835 | ||
| 1835 | 1836 | ||
| 1836 | 1837 | const buf2 = Buffer.from('tést'); | |
| 1837 | 1838 | ||
| 1838 | - // Prints: tés | ||
| 1839 | - console.log(buf.toString('utf8', 0, 3)); | ||
| 1839 | + // Prints: 74c3a97374 | ||
| 1840 | + console.log(buf2.toString('hex')); | ||
| 1841 | + | ||
| 1842 | + // Prints: té | ||
| 1843 | + console.log(buf2.toString('utf8', 0, 3)); | ||
| 1840 | 1844 | ||
| 1841 | - // Prints: tés | ||
| 1842 | - console.log(buf.toString(undefined, 0, 3)); | ||
| 1845 | + // Prints: té | ||
| 1846 | + console.log(buf2.toString(undefined, 0, 3)); | ||
| 1843 | 1847 | ``` | |
| 1844 | 1848 | ||
| 1845 | 1849 | ### buf.toJSON() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments