Skip to content

Commit

Permalink
lib: add Windows-31J alias for CP932
Browse files Browse the repository at this point in the history
Fixes #152.
  • Loading branch information
bnoordhuis committed Apr 27, 2016
1 parent af789d1 commit 0d085a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/iconv.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ util.inherits(Iconv, stream.Stream);

function fixEncoding(encoding)
{
if (/^windows-31j$/i.test(encoding)) return 'cp932';
// Convert "utf8" to "utf-8".
return /^utf[^-]/i.test(encoding) ? 'utf-' + encoding.substr(3) : encoding;
}
Expand Down
3 changes: 3 additions & 0 deletions test/test-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ new Iconv('utf16', 'utf32');
new Iconv('utf16le', 'utf16be');
new Iconv('utf32le', 'utf32be');

// https://github.com/bnoordhuis/node-iconv/issues/152
new Iconv('windows-31J', 'windows-31j');

var iconv = new Iconv('utf-8', 'iso-8859-1');
assert.throws(function() { iconv.convert() });
assert.throws(function() { iconv.convert(1) });
Expand Down

0 comments on commit 0d085a4

Please sign in to comment.