{"_id":"charset","_rev":"2815866","name":"charset","description":"Get the content charset from header and html content-type.","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"modified":"2022-09-06T14:06:12.000Z","created":"2012-10-08T12:01:27.978Z","1.0.1":"2017-09-07T03:00:30.260Z","1.0.0":"2014-09-17T13:59:01.291Z","0.1.0":"2014-07-05T12:42:11.383Z","0.0.2":"2014-01-19T12:44:35.269Z","0.0.1":"2012-10-08T12:01:27.978Z"},"users":{},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://fengmk2.com"},"repository":{"type":"git","url":"git://github.com/node-modules/charset.git"},"versions":{"1.0.1":{"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":{"shasum":"8d59546c355be61049a8fa9164747793319852bd","size":17799,"noattachment":false,"key":"/charset/-/charset-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/charset/download/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":{},"publish_time":1504753230260,"_hasShrinkwrap":false,"_cnpm_publish_time":1504753230260,"_cnpmcore_publish_time":"2021-12-16T16:07:25.676Z"},"1.0.0":{"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","size":5153,"noattachment":false,"key":"/charset/-/charset-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/charset/download/charset-1.0.0.tgz"},"directories":{},"publish_time":1410962341291,"_hasShrinkwrap":false,"_cnpm_publish_time":1410962341291,"_cnpmcore_publish_time":"2021-12-16T16:07:25.876Z"},"0.1.0":{"name":"charset","version":"0.1.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":"b36c23553eb08eed0388ca85d352c67bec4954dd","bugs":{"url":"https://github.com/node-modules/charset/issues"},"_id":"charset@0.1.0","_shasum":"032b4ed95bba940f2c7241e0e890e6bbae569442","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"dist":{"shasum":"032b4ed95bba940f2c7241e0e890e6bbae569442","size":5062,"noattachment":false,"key":"/charset/-/charset-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/charset/download/charset-0.1.0.tgz"},"directories":{},"publish_time":1404564131383,"_hasShrinkwrap":false,"_cnpm_publish_time":1404564131383,"_cnpmcore_publish_time":"2021-12-16T16:07:26.100Z"},"0.0.2":{"name":"charset","version":"0.0.2","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":"3.0.1"},"homepage":"https://github.com/fengmk2/charset","repository":{"type":"git","url":"git://github.com/fengmk2/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","readmeFilename":"README.md","contributors":[{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},{"name":"Oleg Slobodskoi","email":"oleg008@gmail.com","url":"https://github.com/kof"}],"bugs":{"url":"https://github.com/fengmk2/charset/issues"},"_id":"charset@0.0.2","dist":{"shasum":"b8856d86d564c9dd74a7e3a4e7da4407456cec59","size":2856,"noattachment":false,"key":"/charset/-/charset-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/charset/download/charset-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"publish_time":1390135475269,"_hasShrinkwrap":false,"_cnpm_publish_time":1390135475269,"_cnpmcore_publish_time":"2021-12-16T16:07:26.331Z"},"0.0.1":{"name":"charset","version":"0.0.1","description":"Get the content charset from header and html content-type.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"make test"},"devDependencies":{"should":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/charset.git"},"keywords":["charset","content-type","ContentType"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","_id":"charset@0.0.1","dist":{"shasum":"482d4e3fcbac96423f3af72bec7e640b6d43b7f0","size":2108,"noattachment":false,"key":"/charset/-/charset-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/charset/download/charset-0.0.1.tgz"},"_npmVersion":"1.1.61","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"publish_time":1349697687978,"_hasShrinkwrap":false,"_cnpm_publish_time":1349697687978,"_cnpmcore_publish_time":"2021-12-16T16:07:26.580Z"}},"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","_attachments":{},"homepage":"https://github.com/node-modules/charset","bugs":{"url":"https://github.com/node-modules/charset/issues"},"license":"MIT"}