iconv-lite
Advanced tools
Comparing version 0.4.10 to 0.4.11
# 0.4.11 / 2015-07-03 | ||
* Added CESU-8 encoding. | ||
# 0.4.10 / 2015-05-26 | ||
@@ -3,0 +8,0 @@ |
@@ -8,3 +8,3 @@ "use strict" | ||
utf8: { type: "_internal", bomAware: true}, | ||
cesu8: "utf8", | ||
cesu8: { type: "_internal", bomAware: true}, | ||
unicode11utf8: "utf8", | ||
@@ -31,2 +31,6 @@ | ||
this.encoder = InternalEncoderBase64; | ||
else if (this.enc === "cesu8") { | ||
this.enc = "utf8"; // Use utf8 for decoding. | ||
this.encoder = InternalEncoderCesu8; | ||
} | ||
} | ||
@@ -88,1 +92,31 @@ | ||
//------------------------------------------------------------------------------ | ||
// CESU-8 encoder is also special. | ||
function InternalEncoderCesu8(options, codec) { | ||
} | ||
InternalEncoderCesu8.prototype.write = function(str) { | ||
var buf = new Buffer(str.length * 3), bufIdx = 0; | ||
for (var i = 0; i < str.length; i++) { | ||
var charCode = str.charCodeAt(i); | ||
// Naive implementation, but it works because CESU-8 is especially easy | ||
// to convert from UTF-16 (which all JS strings are encoded in). | ||
if (charCode < 0x80) | ||
buf[bufIdx++] = charCode; | ||
else if (charCode < 0x800) { | ||
buf[bufIdx++] = 0xC0 + (charCode >>> 6); | ||
buf[bufIdx++] = 0x80 + (charCode & 0x3f); | ||
} | ||
else { // charCode will always be < 0x10000 in javascript. | ||
buf[bufIdx++] = 0xE0 + (charCode >>> 12); | ||
buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f); | ||
buf[bufIdx++] = 0x80 + (charCode & 0x3f); | ||
} | ||
} | ||
return buf.slice(0, bufIdx); | ||
} | ||
InternalEncoderCesu8.prototype.end = function() { | ||
} |
{ | ||
"name": "iconv-lite", | ||
"description": "Convert character encodings in pure javascript.", | ||
"version": "0.4.10", | ||
"version": "0.4.11", | ||
"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
328075
3848