iconv-lite
Advanced tools
Comparing version 0.4.9 to 0.4.10
# 0.4.10 / 2015-05-26 | ||
* Changed UTF-16 endianness heuristic to take into account any ASCII chars, not | ||
just spaces. This should minimize the importance of "default" endianness. | ||
# 0.4.9 / 2015-05-24 | ||
@@ -3,0 +9,0 @@ |
@@ -154,15 +154,15 @@ "use strict" | ||
// No BOM found. Try to deduce encoding from initial content. | ||
// Most of the time, the content has spaces (U+0020), but the opposite (U+2000) is very uncommon. | ||
// So, we count spaces as if it was LE or BE, and decide from that. | ||
var spacesLE = 0, spacesBE = 0, // Counts of space chars in both positions | ||
// Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon. | ||
// So, we count ASCII as if it was LE or BE, and decide from that. | ||
var asciiCharsLE = 0, asciiCharsBE = 0, // Counts of chars in both positions | ||
_len = Math.min(buf.length - (buf.length % 2), 64); // Len is always even. | ||
for (var i = 0; i < _len; i += 2) { | ||
if (buf[i] == 0x00 && buf[i+1] == 0x20) spacesBE++; | ||
if (buf[i] == 0x20 && buf[i+1] == 0x00) spacesLE++; | ||
if (buf[i] === 0 && buf[i+1] !== 0) asciiCharsBE++; | ||
if (buf[i] !== 0 && buf[i+1] === 0) asciiCharsLE++; | ||
} | ||
if (spacesBE > 0 && spacesLE == 0) | ||
if (asciiCharsBE > asciiCharsLE) | ||
enc = 'utf-16be'; | ||
else if (spacesBE == 0 && spacesLE > 0) | ||
else if (asciiCharsBE < asciiCharsLE) | ||
enc = 'utf-16le'; | ||
@@ -169,0 +169,0 @@ } |
{ | ||
"name": "iconv-lite", | ||
"description": "Convert character encodings in pure javascript.", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
326775