{"name":"charset","version":"1.0.0","description":"Get the content charset from header and html content-type.","main":"index.js","scripts":{"test":"make test-all"},"config":{"blanket":{"pattern":"charset/lib"},"travis-cov":{"threshold":100}},"dependencies":{},"devDependencies":{"autod":"*","blanket":"*","contributors":"*","cov":"*","coveralls":"*","mocha":"*","mocha-lcov-reporter":"*","should":"~4.0.4"},"homepage":"https://github.com/node-modules/charset","repository":{"type":"git","url":"git://github.com/node-modules/charset.git"},"keywords":["charset","content-type","ContentType","Content-Type","xml","encoding"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","contributors":[{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},{"name":"kof","email":"oleg008@gmail.com","url":"https://github.com/kof"}],"gitHead":"05d4b07959019655d08ab59427d2b99b610327c8","bugs":{"url":"https://github.com/node-modules/charset/issues"},"_id":"charset@1.0.0","_shasum":"19327217c249c912e964efbd47f56cc254c348d9","_from":".","_npmVersion":"2.0.0-beta.3","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"dist":{"shasum":"19327217c249c912e964efbd47f56cc254c348d9","tarball":"http://registry-npm.ywwl.com/charset/download/charset-1.0.0.tgz","integrity":"sha512-koQGAEXbNHlaiNlUo4OSH3x8awp8XZHS2Q6Pzws0JRTiR8f/3PZpdr2ZWEBq/rC37+QqN7025BBsSvQYchhnIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCIHpv930TMkQuajsMl98amdQJGG8Cqg+1dymL001D0oS0Ah8dVkBDAHgw/SSRQSKj/xdWRSXwOaCuqLQBcluYZMuW"}],"size":5153,"noattachment":false,"key":"/charset/-/charset-1.0.0.tgz"},"directories":{},"readme":"charset\n=======\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/charset.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/charset\n[travis-image]: https://img.shields.io/travis/node-modules/charset.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/charset\n[codecov-image]: https://codecov.io/gh/node-modules/charset/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/charset\n[david-image]: https://img.shields.io/david/node-modules/charset.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/charset\n[download-image]: https://img.shields.io/npm/dm/charset.svg?style=flat-square\n[download-url]: https://npmjs.org/package/charset\n\n![logo](https://raw.github.com/node-modules/charset/master/logo.png)\n\nGet the content charset from header and html content-type.\n\n## Install\n\n```bash\n$ npm install charset --save\n```\n\n## Usage\n\n### Detect charset from http client response and content\n\n```js\nvar charset = require('charset');\nvar http = require('http');\n\nhttp.get('http://nodejs.org', function (res) {\n  res.on('data', function (chunk) {\n    console.log(charset(res.headers, chunk));\n    // or `console.log(charset(res, chunk));`\n    res.destroy();\n  });\n});\n```\n\nStdout will should log: `utf8` .\n\n### Detect from String\n\n```js\ncharset(res.headers['content-type']);\n```\n\n### Detect combine with [jschardet]\n\nAs you know, `charset` only detect from http response headers and html content-type meta tag.\nYou can combine with [jschardet] to help you detect the finally charset.\n\nThis example codes come from [stackoverflow#12326688](http://stackoverflow.com/a/18712021/2496088):\n\n```js\nvar request = require('request');\nvar charset = require('charset');\nvar jschardet = require('jschardet');\n\nrequest({\n  url: 'http://www.example.com',\n  encoding: null\n}, function (err, res, body) {\n  if (err) {\n    throw err;\n  }\n  enc = charset(res.headers, body);\n  enc = enc || jschardet.detect(body).encoding.toLowerCase();\n  console.log(enc);\n});\n```\n\n## License\n\n[MIT](LICENSE.txt)\n\n[jschardet]: https://github.com/aadsm/jschardet\n","publish_time":1410962341291,"_cnpm_publish_time":1410962341291,"dist-tags":{"latest":"1.0.1"}}