Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: add string_decoder doc
Browse files Browse the repository at this point in the history
  • Loading branch information
shama authored and bnoordhuis committed Apr 20, 2012
1 parent c21c51a commit d91ef15
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/api/string_decoder.markdown
@@ -0,0 +1,24 @@
# StringDecoder

Stability: 2 - Unstable

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.

var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');

var cent = new Buffer([0xC2, 0xA2]);
console.log(decoder.write(cent));

var euro = new Buffer([0xE2, 0x82, 0xAC]);
console.log(decoder.write(euro));

## Class: StringDecoder

Accepts a single argument, `encoding` which defaults to `utf8`.

### StringDecoder.write(buffer)

Returns a decoded string.

0 comments on commit d91ef15

Please sign in to comment.