charset

WebJar for charset

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

charset
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

charset
WebJar for charset
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/node-modules/charset

Скачать charset

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/charset/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>charset</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/charset/
implementation 'org.webjars.npm:charset:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/charset/
implementation ("org.webjars.npm:charset:1.0.1")
'org.webjars.npm:charset:jar:1.0.1'
<dependency org="org.webjars.npm" name="charset" rev="1.0.1">
  <artifact name="charset" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='charset', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "charset" % "1.0.1"
[org.webjars.npm/charset "1.0.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

charset

NPM version build status Test coverage David deps npm download

logo

Get the content charset from header and html content-type.

Install

$ npm install charset --save

Usage

Detect charset from http client response and content

var charset = require('charset');
var http = require('http');

http.get('http://nodejs.org', function (res) {
  res.on('data', function (chunk) {
    console.log(charset(res.headers, chunk));
    // or `console.log(charset(res, chunk));`
    res.destroy();
  });
});

Stdout will should log: utf8 .

Detect from String

charset(res.headers['content-type']);

Detect combine with jschardet

As you know, charset only detect from http response headers and html content-type meta tag. You can combine with jschardet to help you detect the finally charset.

This example codes come from stackoverflow#12326688:

var request = require('request');
var charset = require('charset');
var 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 || jschardet.detect(body).encoding.toLowerCase();
  console.log(enc);
});

License

MIT

org.webjars.npm

node_modules

All about node.js modules like your project 'node_modules' dir

Версии библиотеки

Версия
1.0.1