{"name":"charset","version":"1.0.1","description":"Get the content charset from header and html content-type.","main":"index.js","scripts":{"test":"npm run lint && egg-bin test","ci":"npm run lint && egg-bin cov","lint":"eslint test *.js"},"dependencies":{},"devDependencies":{"egg-bin":"1","egg-ci":"^1.1.0","eslint":"4","eslint-config-egg":"5"},"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"],"engines":{"node":">=4.0.0"},"ci":{"version":"4, 6, 8"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://fengmk2.com"},"license":"MIT","contributors":[{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},{"name":"Oleg Slobodskoi","email":"oleg008@gmail.com","url":"https://github.com/kof"}],"gitHead":"dcc48ee609a9b8a137c68faad712c646fcaeda29","bugs":{"url":"https://github.com/node-modules/charset/issues"},"_id":"charset@1.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"integrity":"sha512-6dVyOOYjpfFcL1Y4qChrAoQLRHvj2ziyhcm0QJlhOcAhykL/k1kTUPbeo+87MNRTRdk2OIIsIXbuF3x2wi5EXg==","shasum":"8d59546c355be61049a8fa9164747793319852bd","tarball":"http://registry-npm.ywwl.com/charset/download/charset-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDf2iQZ7hIcWJQozOc1btfvJaMeHPoHLq8oIkAgBK/s+wIgLZXHLfVeuQbHkDbm8I/hahKe3i0GomNZkatkzeznb1c="}],"size":17799,"noattachment":false,"key":"/charset/-/charset-1.0.1.tgz"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/charset-1.0.1.tgz_1504753230155_0.8552967752330005"},"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":1504753230260,"_cnpm_publish_time":1504753230260,"dist-tags":{"latest":"1.0.1"}}