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