This commit is contained in:
Dmitry Shirokov 2015-11-30 08:51:34 +11:00
parent 9609ab4a7a
commit 45564fbfbe
3 changed files with 11 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
testing.js testing.js
.DS_Store .DS_Store
node_modules

View File

@ -14,8 +14,7 @@ module.exports.UTF_16BE = function() {
var input = det.fRawInput; var input = det.fRawInput;
if (input.length >= 2 && ((input[0] & 0xff) == 0xfe && (input[1] & 0xff) == 0xff)) { if (input.length >= 2 && ((input[0] & 0xff) == 0xfe && (input[1] & 0xff) == 0xff)) {
var confidence = 100; return new Match(det, this, 100); // confidence = 100
return new Match(det, this, confidence);
} }
// TODO: Do some statistics to check for unsigned UTF-16BE // TODO: Do some statistics to check for unsigned UTF-16BE
@ -31,13 +30,12 @@ module.exports.UTF_16LE = function() {
var input = det.fRawInput; var input = det.fRawInput;
if (input.length >= 2 && ((input[0] & 0xff) == 0xff && (input[1] & 0xff) == 0xfe)) { if (input.length >= 2 && ((input[0] & 0xff) == 0xff && (input[1] & 0xff) == 0xfe)) {
// An LE BOM is present. // LE BOM is present.
if (input.length >= 4 && input[2] == 0x00 && input[3] == 0x00) { if (input.length >= 4 && input[2] == 0x00 && input[3] == 0x00) {
// It is probably UTF-32 LE, not UTF-16 // It is probably UTF-32 LE, not UTF-16
return null; return null;
} }
var confidence = 100; return new Match(det, this, 100); // confidence = 100
return new Match(det, this, confidence);
} }
// TODO: Do some statistics to check for unsigned UTF-16LE // TODO: Do some statistics to check for unsigned UTF-16LE

View File

@ -1,6 +1,6 @@
{ {
"name": "chardet", "name": "chardet",
"version": "0.0.8", "version": "0.1.0",
"homepage": "https://github.com/runk/node-chardet", "homepage": "https://github.com/runk/node-chardet",
"description": "Character detector", "description": "Character detector",
"keywords": [ "keywords": [
@ -12,6 +12,9 @@
"icu" "icu"
], ],
"author": "Dmitry Shirokov <deadrunk@gmail.com>", "author": "Dmitry Shirokov <deadrunk@gmail.com>",
"contributors": [
"@spikying"
],
"devDependencies": { "devDependencies": {
"mocha": ">= 1.8" "mocha": ">= 1.8"
}, },