[Pkg-javascript-commits] [node-iconv-lite] 67/83: Version 0.2.10: Accept binary-encoded strings as a source when decoding
matthew pideil
mpideil-guest at moszumanska.debian.org
Tue Apr 1 19:56:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
mpideil-guest pushed a commit to branch master
in repository node-iconv-lite.
commit 0dc603d6fe3ea8d2cb9b3af37f43d3e66b5dfb7d
Author: Alexander Shtuchkin <ashtuchkin at gmail.com>
Date: Sun May 26 00:04:56 2013 +0400
Version 0.2.10: Accept binary-encoded strings as a source when decoding
We accepted strings before, but they were converted to Buffer as 'utf8'.
'binary' encoding is making much more sense.
---
README.md | 1 +
index.js | 4 ++--
package.json | 2 +-
test/main-test.js | 4 ++--
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 66de64e..6bea38f 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ Note: your results may vary, so please always check on your hardware.
## Notes
+When decoding, a 'binary'-encoded string can be used as a source buffer.
Untranslatable characters are set to � or ?. No transliteration is currently supported, pull requests are welcome.
## Testing
diff --git a/index.js b/index.js
index 92eb818..f8f904d 100644
--- a/index.js
+++ b/index.js
@@ -208,12 +208,12 @@ var asciiString = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x1
var ensureBuffer = function(buf) {
buf = buf || new Buffer(0);
- return (buf instanceof Buffer) ? buf : new Buffer(buf.toString(), "utf8");
+ return (buf instanceof Buffer) ? buf : new Buffer(""+buf, "binary");
}
var ensureString = function(str) {
str = str || "";
- return (str instanceof String) ? str : str.toString((str instanceof Buffer) ? 'utf8' : undefined);
+ return (str instanceof Buffer) ? str.toString('utf8') : (""+str);
}
var getType = function(obj) {
diff --git a/package.json b/package.json
index a95c96d..ac810ad 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "iconv-lite",
"description": "Convert character encodings in pure javascript.",
- "version": "0.2.9",
+ "version": "0.2.10",
"license": "MIT",
"keywords": ["iconv", "convert", "charset"],
diff --git a/test/main-test.js b/test/main-test.js
index 072c599..50177f2 100644
--- a/test/main-test.js
+++ b/test/main-test.js
@@ -28,8 +28,8 @@ vows.describe("Generic UTF8-UCS2 tests").addBatch({
assert.strictEqual(iconv.toEncoding(testStringLatin1, "latin1").toString("binary"), testStringLatin1);
assert.strictEqual(iconv.fromEncoding(new Buffer(testStringLatin1, "binary"), "latin1"), testStringLatin1);
},
- "Convert from string, not buffer (utf8 used)": function() {
- assert.strictEqual(iconv.fromEncoding(testStringLatin1, "utf8"), testStringLatin1);
+ "Convert from string, not buffer (binary encoding used)": function() {
+ assert.strictEqual(iconv.fromEncoding(testStringLatin1, "binary"), testStringLatin1);
},
"Convert to string, not buffer (utf8 used)": function() {
var res = iconv.toEncoding(new Buffer(testStringLatin1, "utf8"));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iconv-lite.git
More information about the Pkg-javascript-commits
mailing list