Projects
openEuler:24.03:SP1:Everything:64G
nodejs-iconv
_service:tar_scm:nodejs-iconv-glibc.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:nodejs-iconv-glibc.patch of Package nodejs-iconv
commit a690ba5b71acb62cc3949a78eea0c73caae69cd8 Author: Tom Hughes <tom@compton.nu> Date: Tue Nov 24 14:13:26 2015 +0000 Workaround differences in glibc iconv diff --git a/lib/iconv.js b/lib/iconv.js index 84a2d75..97b4707 100644 --- a/lib/iconv.js +++ b/lib/iconv.js @@ -54,13 +54,15 @@ function Iconv(fromEncoding, toEncoding) toEncoding + ' is not supported.'); } + var ignore = toEncoding.match(/\/\/IGNORE(\/|$)/i); + var context_ = { trailer: null }; this.convert = function(input, encoding) { if (typeof(input) === 'string') { input = Buffer.from(input, encoding || 'utf8'); } - return convert(conv, input, null); + return convert(conv, ignore, input, null); }; this.write = function(input, encoding) { @@ -68,7 +70,7 @@ function Iconv(fromEncoding, toEncoding) input = Buffer.from(input, encoding || 'utf8'); } try { - var buf = convert(conv, input, context_); + var buf = convert(conv, ignore, input, context_); } catch (e) { this.emit('error', e); @@ -97,7 +99,7 @@ function fixEncoding(encoding) return /^utf[^-]/i.test(encoding) ? 'utf-' + encoding.substr(3) : encoding; } -function convert(conv, input, context) { +function convert(conv, ignore, input, context) { if (!Buffer.isBuffer(input) && input !== FLUSH) { throw new Error('Bad argument.'); // Not a buffer or a string. } @@ -141,7 +143,7 @@ function convert(conv, input, context) { input_size -= input_consumed; output_start += output_consumed; output_size -= output_consumed; - if (errno) { + if (errno && !(errno === EILSEQ && ignore)) { if (errno === E2BIG) { output_size += output.length; var newbuf = Buffer.alloc(output.length * 2); diff --git a/test/test-basic.js b/test/test-basic.js index 7cee646..19e5e89 100644 --- a/test/test-basic.js +++ b/test/test-basic.js @@ -130,22 +130,22 @@ iconv = new Iconv('utf-8', 'ascii//ignore'); assert.equal(iconv.convert('ça va').toString(), 'a va'); iconv = new Iconv('utf-8', 'ascii//translit'); -assert.equal(iconv.convert('ça va').toString(), 'ca va'); +assert.equal(iconv.convert('ça va').toString(), '?a va'); iconv = new Iconv('utf-8', 'ascii//translit'); -assert.throws(function() { iconv.convert('ça va が'); }); // untranslatable +assert.equal(iconv.convert('ça va が').toString(), '?a va ?'); iconv = new Iconv('utf-8', 'ascii//translit//ignore'); -assert.equal(iconv.convert('ça va が').toString(), 'ca va '); +assert.equal(iconv.convert('ça va が').toString(), '?a va ?'); iconv = Iconv('utf-8', 'iso-8859-1'); assert.equal(iconv.convert('b2s=', 'base64').toString(), 'ok'); var aixEncodings = - 'CP856 CP922 CP943 CP1046 CP1124 CP1129 CP1161 CP1162 CP1163'; + 'CP856 CP922 CP1046 CP1124 CP1129 CP1161 CP1162 CP1163'; var dosEncodings = - 'CP437 CP737 CP775 CP852 CP853 CP855 CP857 CP858 CP860 CP861 ' + + 'CP437 CP737 CP775 CP852 CP855 CP857 CP860 CP861 ' + 'CP863 CP864 CP865 CP869 CP1125'; // Check that AIX and DOS encodings are available.
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2