mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
doc: git mv to .md
* doc: rename .markdown references in content * doc: rename to .md in tools * doc: rename to .md in CONTRIBUTING.md PR-URL: https://github.com/nodejs/node/pull/4747 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: techjeffharris Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
cff2a137f2
commit
0800c0aa72
50 files changed
+32
-32
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# StringDecoder
|
||||
|
||||
Stability: 2 - Stable
|
||||
|
||||
To use this module, do `require('string_decoder')`. StringDecoder decodes a
|
||||
buffer to a string. It is a simple interface to `buffer.toString()` but provides
|
||||
additional support for utf8.
|
||||
|
||||
```js
|
||||
const StringDecoder = require('string_decoder').StringDecoder;
|
||||
const decoder = new StringDecoder('utf8');
|
||||
|
||||
const cent = new Buffer([0xC2, 0xA2]);
|
||||
console.log(decoder.write(cent));
|
||||
|
||||
const euro = new Buffer([0xE2, 0x82, 0xAC]);
|
||||
console.log(decoder.write(euro));
|
||||
```
|
||||
|
||||
## Class: StringDecoder
|
||||
|
||||
Accepts a single argument, `encoding` which defaults to `'utf8'`.
|
||||
|
||||
### decoder.end()
|
||||
|
||||
Returns any trailing bytes that were left in the buffer.
|
||||
|
||||
### decoder.write(buffer)
|
||||
|
||||
Returns a decoded string.
|
||||
Reference in new issue
Block a user