Skip to content

Commit

Permalink
Merge pull request #6 from teambition/master
Browse files Browse the repository at this point in the history
fix example with jschardet
  • Loading branch information
fengmk2 committed Jan 4, 2015
2 parents c2f94ef + 4787184 commit 77fb038
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 77fb038

Please sign in to comment.