Skip to content

Commit d91ef15

Browse files
shamabnoordhuis
authored andcommitted
doc: add string_decoder doc
1 parent c21c51a commit d91ef15

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

doc/api/string_decoder.markdown

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# StringDecoder
2+
3+
Stability: 2 - Unstable
4+
5+
To use this module, do `require('string_decoder')`. StringDecoder decodes a
6+
buffer to a string. It is a simple interface to `buffer.toString()` but provides
7+
additional support for utf8.
8+
9+
var StringDecoder = require('string_decoder').StringDecoder;
10+
var decoder = new StringDecoder('utf8');
11+
12+
var cent = new Buffer([0xC2, 0xA2]);
13+
console.log(decoder.write(cent));
14+
15+
var euro = new Buffer([0xE2, 0x82, 0xAC]);
16+
console.log(decoder.write(euro));
17+
18+
## Class: StringDecoder
19+
20+
Accepts a single argument, `encoding` which defaults to `utf8`.
21+
22+
### StringDecoder.write(buffer)
23+
24+
Returns a decoded string.

0 commit comments

Comments
 (0)