Skip to content

Commit

Permalink
fix example with jschardet
Browse files Browse the repository at this point in the history
  • Loading branch information
sailxjx committed Jan 4, 2015
1 parent c2f94ef commit 4787184
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ You can combine with [jschardet] to help you detect the finally charset.
This example codes come from [stackoverflow#12326688](http://stackoverflow.com/a/18712021/2496088):

```js
var charset = require('charset');
var jschardet = require('jschardet');

request('http://www.example.com', function (err, res, body) {
if (!err) {
var request = require('request'),
charset = require('charset'),
jschardet = require('jschardet');

request({
url: 'http://www.example.com',
encoding: null
}, function (err, res, body) {
if (err) {
throw err;
}

enc = charset(res.headers, body);
enc = enc or jschardet.detect(body).encoding.toLowerCase();
enc = enc || jschardet.detect(body).encoding.toLowerCase();
console.log(enc);
});
```
Expand Down

0 comments on commit 4787184

Please # to comment.