[Pkg-javascript-commits] [node-iconv-lite] 01/01: Initial import of iconv-lite version 0.2.11

matthew pideil mpideil-guest at moszumanska.debian.org
Sun Apr 13 10:44:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

mpideil-guest pushed a commit to tag 0.2.11
in repository node-iconv-lite.

commit 127c2cd4ebf77da1f578b3c967f776efe139e453
Author: Matthew Pideil <matthewp_debian at teledetection.fr>
Date:   Sun Apr 13 10:30:20 2014 +0000

    Initial import of iconv-lite version 0.2.11
---
 .gitignore                        |   3 +
 .travis.yml                       |   5 +
 LICENSE                           |  21 +++
 README.md                         |  72 ++++++++
 encodings/big5.js                 |   9 +
 encodings/gbk.js                  |   9 +
 encodings/singlebyte.js           | 340 ++++++++++++++++++++++++++++++++++++++
 encodings/table/big5.js           |   1 +
 encodings/table/gbk.js            |   1 +
 generation/generate-big5-table.js |  25 +++
 generation/generate-singlebyte.js | 142 ++++++++++++++++
 index.js                          | 231 ++++++++++++++++++++++++++
 package.json                      |  38 +++++
 test/big5-test.js                 |  36 ++++
 test/big5File.txt                 |  13 ++
 test/cyrillic-test.js             |  86 ++++++++++
 test/gbk-test.js                  |  38 +++++
 test/gbkFile.txt                  |  14 ++
 test/greek-test.js                |  79 +++++++++
 test/main-test.js                 |  55 ++++++
 test/performance.js               |  67 ++++++++
 test/turkish-test.js              |  90 ++++++++++
 22 files changed, 1375 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fe46877
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+*~
+*sublime-*
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..0bab9cd
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+ language: node_js
+ node_js:
+   - 0.4
+   - 0.6
+   - 0.8
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d518d83
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011 Alexander Shtuchkin
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ba30a32
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+iconv-lite - pure javascript character encoding conversion
+======================================================================
+
+[![Build Status](https://secure.travis-ci.org/ashtuchkin/iconv-lite.png?branch=master)](http://travis-ci.org/ashtuchkin/iconv-lite)
+
+## Features
+
+*   Pure javascript. Doesn't need native code compilation.
+*   Easy API.
+*   Works on Windows and in sandboxed environments like [Cloud9](http://c9.io).
+*   Encoding is much faster than node-iconv (see below for performance comparison).
+
+## Usage
+
+    var iconv = require('iconv-lite');
+    
+    // Convert from an encoded buffer to string.
+    str = iconv.decode(buf, 'win1251');
+    
+    // Convert from string to an encoded buffer.
+    buf = iconv.encode("Sample input string", 'win1251');
+
+    // Check if encoding is supported
+    iconv.encodingExists("us-ascii")
+
+
+## Supported encodings
+
+*   All node.js native encodings: 'utf8', 'ucs2', 'ascii', 'binary', 'base64'
+*   All widespread single byte encodings: Windows 125x family, ISO-8859 family, 
+    IBM/DOS codepages, Macintosh family, KOI8 family. 
+    Aliases like 'latin1', 'us-ascii' also supported.
+*   Multibyte encodings: 'gbk', 'gb2313', 'Big5', 'cp950'.
+
+Others are easy to add, see the source. Please, participate.
+Most encodings are generated from node-iconv. Thank you Ben Noordhuis and iconv authors!
+
+Not supported yet: EUC family, Shift_JIS.
+
+
+## Encoding/decoding speed
+
+Comparison with node-iconv module (1000x256kb, on Ubuntu 12.04, Core i5/2.5 GHz, Node v0.8.7). 
+Note: your results may vary, so please always check on your hardware.
+
+    operation             iconv at 1.2.4   iconv-lite at 0.2.4 
+    ----------------------------------------------------------
+    encode('win1251')     ~115 Mb/s     ~230 Mb/s
+    decode('win1251')     ~95 Mb/s      ~130 Mb/s
+
+
+## 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
+
+    git clone git at github.com:ashtuchkin/iconv-lite.git
+    cd iconv-lite
+    npm install
+    npm test
+    
+    # To view performance:
+    node test/performance.js
+
+## TODO
+
+*   Support streaming character conversion, something like util.pipe(req, iconv.fromEncodingStream('latin1')).
+*   Add more encodings.
+*   Add transliteration (best fit char).
+*   Add tests and correct support of variable-byte encodings (currently work is delegated to node).
diff --git a/encodings/big5.js b/encodings/big5.js
new file mode 100644
index 0000000..0423d63
--- /dev/null
+++ b/encodings/big5.js
@@ -0,0 +1,9 @@
+var big5Table = require('./table/big5.js');
+module.exports = {
+	'windows950': 'big5',
+	'cp950': 'big5',
+	'big5': {
+		type: 'table',
+		table: big5Table
+	}
+}
diff --git a/encodings/gbk.js b/encodings/gbk.js
new file mode 100644
index 0000000..78a63ec
--- /dev/null
+++ b/encodings/gbk.js
@@ -0,0 +1,9 @@
+var gbkTable = require('./table/gbk.js');
+module.exports = {
+	'windows936': 'gbk',
+	'gb2312': 'gbk',
+	'gbk': {
+		type: 'table',
+		table: gbkTable
+	}
+}
diff --git a/encodings/singlebyte.js b/encodings/singlebyte.js
new file mode 100644
index 0000000..f41a7ea
--- /dev/null
+++ b/encodings/singlebyte.js
@@ -0,0 +1,340 @@
+module.exports = {
+  "437": "cp437",
+  "737": "cp737",
+  "775": "cp775",
+  "850": "cp850",
+  "852": "cp852",
+  "855": "cp855",
+  "857": "cp857",
+  "858": "cp858",
+  "860": "cp860",
+  "861": "cp861",
+  "862": "cp862",
+  "863": "cp863",
+  "864": "cp864",
+  "865": "cp865",
+  "866": "cp866",
+  "869": "cp869",
+  "874": "iso885911",
+  "1250": "windows1250",
+  "1251": "windows1251",
+  "1252": "windows1252",
+  "1253": "windows1253",
+  "1254": "windows1254",
+  "1255": "windows1255",
+  "1256": "windows1256",
+  "1257": "windows1257",
+  "1258": "windows1258",
+  "10000": "macroman",
+  "10006": "macgreek",
+  "10007": "maccyrillic",
+  "10029": "maccenteuro",
+  "10079": "maciceland",
+  "10081": "macturkish",
+  "20866": "koi8r",
+  "21866": "koi8u",
+  "28591": "iso88591",
+  "28592": "iso88592",
+  "28593": "iso88593",
+  "28594": "iso88594",
+  "28595": "iso88595",
+  "28596": "iso88596",
+  "28597": "iso88597",
+  "28598": "iso88598",
+  "28599": "iso88599",
+  "28600": "iso885910",
+  "28601": "iso885911",
+  "28603": "iso885913",
+  "28604": "iso885914",
+  "28605": "iso885915",
+  "28606": "iso885916",
+  "ascii8bit": "ascii",
+  "usascii": "ascii",
+  "latin1": "iso88591",
+  "latin2": "iso88592",
+  "latin3": "iso88593",
+  "latin4": "iso88594",
+  "latin6": "iso885910",
+  "latin7": "iso885913",
+  "latin8": "iso885914",
+  "latin9": "iso885915",
+  "latin10": "iso885916",
+  "cp819": "iso88951",
+  "arabic": "iso88596",
+  "arabic8": "iso88596",
+  "greek": "iso88597",
+  "greek8": "iso88597",
+  "hebrew": "iso88598",
+  "hebrew8": "iso88598",
+  "turkish": "iso88599",
+  "turkish8": "iso88599",
+  "thai": "iso885911",
+  "thai8": "iso885911",
+  "tis620": "iso885911",
+  "windows874": "iso885911",
+  "win874": "iso885911",
+  "cp874": "iso885911",
+  "celtic": "iso885914",
+  "celtic8": "iso885914",
+  "cp20866": "koi8r",
+  "ibm878": "koi8r",
+  "cp21866": "koi8u",
+  "ibm1168": "koi8u",
+  "windows1250": {
+    "type": "singlebyte",
+    "chars": "€�‚�„…†‡�‰Š‹ŚŤŽŹ�‘’“”•–—�™š›śťžź ˇ˘Ł¤Ą¦§¨©Ş«¬­®Ż°±˛ł´µ¶·¸ąş»Ľ˝ľżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙"
+  },
+  "win1250": "windows1250",
+  "cp1250": "windows1250",
+  "windows1251": {
+    "type": "singlebyte",
+    "chars": "ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—�™љ›њќћџ ЎўЈ¤Ґ¦§Ё©Є«¬­®Ї°±Ііґµ¶·ё№є»јЅѕїАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя"
+  },
+  "win1251": "windows1251",
+  "cp1251": "windows1251",
+  "windows1252": {
+    "type": "singlebyte",
+    "chars": "€�‚ƒ„…†‡ˆ‰Š‹Œ�Ž��‘’“”•–—˜™š›œ�žŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
+  },
+  "win1252": "windows1252",
+  "cp1252": "windows1252",
+  "windows1253": {
+    "type": "singlebyte",
+    "chars": "€�‚ƒ„…†‡�‰�‹�����‘’“”•–—�™�›���� ΅Ά£¤¥¦§¨©�«¬­®―°±²³΄µ¶·ΈΉΊ»Ό½ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ�ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ�"
+  },
+  "win1253": "windows1253",
+  "cp1253": "windows1253",
+  "windows1254": {
+    "type": "singlebyte",
+    "chars": "€�‚ƒ„…†‡ˆ‰Š‹Œ����‘’“”•–—˜™š›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ"
+  },
+  "win1254": "windows1254",
+  "cp1254": "windows1254",
+  "windows1255": {
+    "type": "singlebyte",
+    "chars": "€�‚ƒ„…†‡ˆ‰�‹�����‘’“”•–—˜™�›���� ¡¢£₪¥¦§¨©×«¬­®¯°±²³´µ¶·¸¹÷»¼½¾¿ְֱֲֳִֵֶַָֹ�ֻּֽ־ֿ׀ׁׂ׃װױײ׳״�������אבגדהוזחטיךכלםמןנסעףפץצקרשת��‎‏�"
+  },
+  "win1255": "windows1255",
+  "cp1255": "windows1255",
+  "windows1256": {
+    "type": "singlebyte",
+    "chars": "€پ‚ƒ„…†‡ˆ‰ٹ‹Œچژڈگ‘’“”•–—ک™ڑ›œ‌‍ں ،¢£¤¥¦§¨©ھ«¬­®¯°±²³´µ¶·¸¹؛»¼½¾؟ہءآأؤإئابةتثجحخدذرزسشصض×طظعغـفقكàلâمنهوçèéêëىيîïًٌٍَôُِ÷ّùْûü‎‏ے"
+  },
+  "win1256": "windows1256",
+  "cp1256": "windows1256",
+  "windows1257": {
+    "type": "singlebyte",
+    "chars": "€�‚�„…†‡�‰�‹�¨ˇ¸�‘’“”•–—�™�›�¯˛� �¢£¤�¦§Ø©Ŗ«¬­®Æ°±²³´µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåęēčéźėģķīļšńņóōõö÷ųłśūüżž˙"
+  },
+  "win1257": "windows1257",
+  "cp1257": "windows1257",
+  "windows1258": {
+    "type": "singlebyte",
+    "chars": "€�‚ƒ„…†‡ˆ‰�‹Œ����‘’“”•–—˜™�›œ��Ÿ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖ×ØÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ"
+  },
+  "win1258": "windows1258",
+  "cp1258": "windows1258",
+  "iso88591": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
+  },
+  "cp28591": "iso88591",
+  "iso88592": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙"
+  },
+  "cp28592": "iso88592",
+  "iso88593": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ħ˘£¤�Ĥ§¨İŞĞĴ­�Ż°ħ²³´µĥ·¸ışğĵ½�żÀÁÂ�ÄĊĈÇÈÉÊËÌÍÎÏ�ÑÒÓÔĠÖ×ĜÙÚÛÜŬŜßàáâ�äċĉçèéêëìíîï�ñòóôġö÷ĝùúûüŭŝ˙"
+  },
+  "cp28593": "iso88593",
+  "iso88594": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ĄĸŖ¤ĨĻ§¨ŠĒĢŦ­Ž¯°ą˛ŗ´ĩļˇ¸šēģŧŊžŋĀÁÂÃÄÅÆĮČÉĘËĖÍÎĪĐŅŌĶÔÕÖ×ØŲÚÛÜŨŪßāáâãäåæįčéęëėíîīđņōķôõö÷øųúûüũū˙"
+  },
+  "cp28594": "iso88594",
+  "iso88595": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ЁЂЃЄЅІЇЈЉЊЋЌ­ЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђѓєѕіїјљњћќ§ўџ"
+  },
+  "cp28595": "iso88595",
+  "iso88596": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ���¤�������،­�������������؛���؟�ءآأؤإئابةتثجحخدذرزسشصضطظعغ�����ـفقكلمنهوىيًٌٍَُِّْ�������������"
+  },
+  "cp28596": "iso88596",
+  "iso88597": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ‘’£€₯¦§¨©ͺ«¬­�―°±²³΄΅Ά·ΈΉΊ»Ό½ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ�ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ�"
+  },
+  "cp28597": "iso88597",
+  "iso88598": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ �¢£¤¥¦§¨©×«¬­®¯°±²³´µ¶·¸¹÷»¼½¾��������������������������������‗אבגדהוזחטיךכלםמןנסעףפץצקרשת��‎‏�"
+  },
+  "cp28598": "iso88598",
+  "iso88599": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ"
+  },
+  "cp28599": "iso88599",
+  "iso885910": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ĄĒĢĪĨĶ§ĻĐŠŦŽ­ŪŊ°ąēģīĩķ·ļđšŧž―ūŋĀÁÂÃÄÅÆĮČÉĘËĖÍÎÏÐŅŌÓÔÕÖŨØŲÚÛÜÝÞßāáâãäåæįčéęëėíîïðņōóôõöũøųúûüýþĸ"
+  },
+  "cp28600": "iso885910",
+  "iso885911": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����"
+  },
+  "cp28601": "iso885911",
+  "iso885913": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåęēčéźėģķīļšńņóōõö÷ųłśūüżž’"
+  },
+  "cp28603": "iso885913",
+  "iso885914": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ḃḃ£ĊċḊ§Ẁ©ẂḋỲ­®ŸḞḟĠġṀṁ¶ṖẁṗẃṠỳẄẅṡÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏŴÑÒÓÔÕÖṪØÙÚÛÜÝŶßàáâãäåæçèéêëìíîïŵñòóôõöṫøùúûüýŷÿ"
+  },
+  "cp28604": "iso885914",
+  "iso885915": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
+  },
+  "cp28605": "iso885915",
+  "iso885916": {
+    "type": "singlebyte",
+    "chars": "€‚ƒ„
†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ĄąŁ€„Š§š©Ș«Ź­źŻ°±ČłŽ”¶·žčș»ŒœŸżÀÁÂĂÄĆÆÇÈÉÊËÌÍÎÏĐŃÒÓÔŐÖŚŰÙÚÛÜĘȚßàáâăäćæçèéêëìíîïđńòóôőöśűùúûüęțÿ"
+  },
+  "cp28606": "iso885916",
+  "cp437": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm437": "cp437",
+  "cp737": {
+    "type": "singlebyte",
+    "chars": "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ωάέήϊίόύϋώΆΈΉΊΌΎΏ±≥≤ΪΫ÷≈°∙·√ⁿ²■ "
+  },
+  "ibm737": "cp737",
+  "cp775": {
+    "type": "singlebyte",
+    "chars": "ĆüéāäģåćłēŖŗīŹÄÅÉæÆōöĢ¢ŚśÖÜø£ØפĀĪóŻżź”¦©®¬½¼Ł«»░▒▓│┤ĄČĘĖ╣║╗╝ĮŠ┐└┴┬├─┼ŲŪ╚╔╩╦╠═╬Žąčęėįšųūž┘┌█▄▌▐▀ÓßŌŃõÕµńĶķĻļņĒŅ’­±“¾¶§÷„°∙·¹³²■ "
+  },
+  "ibm775": "cp775",
+  "cp850": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ "
+  },
+  "ibm850": "cp850",
+  "cp852": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁ×čáíóúĄąŽžĘ꬟Ⱥ«»░▒▓│┤ÁÂĚŞ╣║╗╝Żż┐└┴┬├─┼Ăă╚╔╩╦╠═╬¤đĐĎËďŇÍÎě┘┌█▄ŢŮ▀ÓßÔŃńňŠšŔÚŕŰýÝţ´­˝˛ˇ˘§÷¸°¨˙űŘř■ "
+  },
+  "ibm852": "cp852",
+  "cp855": {
+    "type": "singlebyte",
+    "chars": "ђЂѓЃёЁєЄѕЅіІїЇјЈљЉњЊћЋќЌўЎџЏюЮъЪаАбБцЦдДеЕфФгГ«»░▒▓│┤хХиИ╣║╗╝йЙ┐└┴┬├─┼кК╚╔╩╦╠═╬¤лЛмМнНоОп┘┌█▄Пя▀ЯрРсСтТуУжЖвВьЬ№­ыЫзЗшШэЭщЩчЧ§■ "
+  },
+  "ibm855": "cp855",
+  "cp857": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèïîıÄÅÉæÆôöòûùİÖÜø£ØŞşáíóúñÑĞ𿮬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ºªÊËÈ�ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµ�×ÚÛÙìÿ¯´­±�¾¶§÷¸°¨·¹³²■ "
+  },
+  "ibm857": "cp857",
+  "cp858": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈ€ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݯ´­±‗¾¶§÷¸°¨·¹³²■ "
+  },
+  "ibm858": "cp858",
+  "cp860": {
+    "type": "singlebyte",
+    "chars": "ÇüéâãàÁçêÊèÍÔìÃÂÉÀÈôõòÚùÌÕÜ¢£Ù₧ÓáíóúñѪº¿Ò¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm860": "cp860",
+  "cp861": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèÐðÞÄÅÉæÆôöþûÝýÖÜø£Ø₧ƒáíóúÁÍÓÚ¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm861": "cp861",
+  "cp862": {
+    "type": "singlebyte",
+    "chars": "אבגדהוזחטיךכלםמןנסעףפץצקרשת¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm862": "cp862",
+  "cp863": {
+    "type": "singlebyte",
+    "chars": "ÇüéâÂà¶çêëèïî‗À§ÉÈÊôËÏûù¤ÔÜ¢£ÙÛƒ¦´óú¨¸³¯Î⌐¬½¼¾«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm863": "cp863",
+  "cp864": {
+    "type": "singlebyte",
+    "chars": "°·∙√▒─│┼┤┬├┴┐┌└┘β∞φ±½¼≈«»ﻷﻸ��ﻻﻼ� ­ﺂ£¤ﺄ��ﺎﺏﺕﺙ،ﺝﺡﺥ٠١٢٣٤٥٦٧٨٩ﻑ؛ﺱﺵﺹ؟¢ﺀﺁﺃﺅﻊﺋﺍﺑﺓﺗﺛﺟﺣﺧﺩﺫﺭﺯﺳﺷﺻﺿﻁﻅﻋﻏ¦¬÷×ﻉـﻓﻗﻛﻟﻣﻧﻫﻭﻯﻳﺽﻌﻎﻍﻡﹽّﻥﻩﻬﻰﻲﻐﻕﻵﻶﻝﻙﻱ■�"
+  },
+  "ibm864": "cp864",
+  "cp865": {
+    "type": "singlebyte",
+    "chars": "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø₧ƒáíóúñѪº¿⌐¬½¼¡«¤░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+  },
+  "ibm865": "cp865",
+  "cp866": {
+    "type": "singlebyte",
+    "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ "
+  },
+  "ibm866": "cp866",
+  "cp869": {
+    "type": "singlebyte",
+    "chars": "������Ά�·¬¦‘’Έ―ΉΊΪΌ��ΎΫ©Ώ²³ά£έήίϊΐόύΑΒΓΔΕΖΗ½ΘΙ«»░▒▓│┤ΚΛΜΝ╣║╗╝ΞΟ┐└┴┬├─┼ΠΡ╚╔╩╦╠═╬ΣΤΥΦΧΨΩαβγ┘┌█▄δε▀ζηθικλμνξοπρσςτ΄­±υφχ§ψ΅°¨ωϋΰώ■ "
+  },
+  "ibm869": "cp869",
+  "maccenteuro": {
+    "type": "singlebyte",
+    "chars": "ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ"
+  },
+  "maccroatian": {
+    "type": "singlebyte",
+    "chars": "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊�©⁄¤‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ"
+  },
+  "maccyrillic": {
+    "type": "singlebyte",
+    "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°¢£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµ∂ЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю¤"
+  },
+  "macgreek": {
+    "type": "singlebyte",
+    "chars": "Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦­ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ�"
+  },
+  "maciceland": {
+    "type": "singlebyte",
+    "chars": "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ"
+  },
+  "macroman": {
+    "type": "singlebyte",
+    "chars": "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ"
+  },
+  "macromania": {
+    "type": "singlebyte",
+    "chars": "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂŞ∞±≤≥¥µ∂∑∏π∫ªºΩăş¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›Ţţ‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ"
+  },
+  "macthai": {
+    "type": "singlebyte",
+    "chars": "«»…“”�•‘’� กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู​–—฿เแโใไๅๆ็่้๊๋์ํ™๏๐๑๒๓๔๕๖๗๘๙®©����"
+  },
+  "macturkish": {
+    "type": "singlebyte",
+    "chars": "ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙ�ˆ˜¯˘˙˚¸˝˛ˇ"
+  },
+  "macukraine": {
+    "type": "singlebyte",
+    "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю¤"
+  },
+  "koi8r": {
+    "type": "singlebyte",
+    "chars": "─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ё╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡Ё╢╣╤╥╦╧╨╩╪╫╬©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ"
+  },
+  "koi8u": {
+    "type": "singlebyte",
+    "chars": "─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ёє╔ії╗╘╙╚╛ґ╝╞╟╠╡ЁЄ╣ІЇ╦╧╨╩╪Ґ╬©юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ"
+  }
+};
diff --git a/encodings/table/big5.js b/encodings/table/big5.js
new file mode 100644
index 0000000..605c72d
--- /dev/null
+++ b/encodings/table/big5.js
@@ -0,0 +1 @@
+module.exports={"33088":19991,"33089":20002,"33090":20012,"33091":20053,"33092":20066,"33093":20106,"33094":20144,"33095":20203,"33096":20205,"33097":20220,"33098":20252,"33099":20362,"33100":20479,"33101":20546,"33102":20560,"33103":20600,"33104":20696,"33105":20702,"33106":20724,"33107":20758,"33108":20810,"33109":20817,"33110":20836,"33111":20842,"33112":20869,"33113":20880,"33114":20893,"33115":20902,"33116":20904,"33117":20905,"33118":20935,"33119":20950,"33120":20955,"33121":20972, [...]
\ No newline at end of file
diff --git a/encodings/table/gbk.js b/encodings/table/gbk.js
new file mode 100644
index 0000000..c464623
--- /dev/null
+++ b/encodings/table/gbk.js
@@ -0,0 +1 @@
+module.exports={33088:19970,33089:19972,33090:19973,33091:19974,33092:19983,33093:19986,33094:19991,33095:19999,33096:20000,33097:20001,33098:20003,33099:20006,33100:20009,33101:20014,33102:20015,33103:20017,33104:20019,33105:20021,33106:20023,33107:20028,33108:20032,33109:20033,33110:20034,33111:20036,33112:20038,33113:20042,33114:20049,33115:20053,33116:20055,33117:20058,33118:20059,33119:20066,33120:20067,33121:20068,33122:20069,33123:20071,33124:20072,33125:20074,33126:20075,33127:20 [...]
\ No newline at end of file
diff --git a/generation/generate-big5-table.js b/generation/generate-big5-table.js
new file mode 100644
index 0000000..909e433
--- /dev/null
+++ b/generation/generate-big5-table.js
@@ -0,0 +1,25 @@
+var http = require('http');
+var fs = require('fs');
+// BIG5
+var cp950_b2u = {host:'moztw.org',path:'/docs/big5/table/cp950-b2u.txt'},
+    cp950_u2b = {host:'moztw.org',path:'/docs/big5/table/cp950-u2b.txt'},
+    cp950_moz18_b2u = {host:'moztw.org',path:'/docs/big5/table/moz18-b2u.txt'};
+
+http.get(cp950_moz18_b2u, function(res) {
+  var data = '';
+  res.on('data', function(chunk) {
+    data += chunk;
+  });
+  res.on('end', function() {
+    var table = {};
+    data = data.split('\n').slice(1);
+    data.forEach(function(line, idx) {
+      var pair = line.split(' ');
+      var key = parseInt(pair[0]);
+      var val = parseInt(pair[1]);
+      table[key] = val;
+    });
+    fs.createWriteSync('encodings/table/big5.js',
+    	'module.exports = ' + JSON.stringify(table) + ';');
+  });
+});
diff --git a/generation/generate-singlebyte.js b/generation/generate-singlebyte.js
new file mode 100644
index 0000000..2cbebec
--- /dev/null
+++ b/generation/generate-singlebyte.js
@@ -0,0 +1,142 @@
+var fs  = require("fs");
+var Iconv  = require("iconv").Iconv;
+
+
+var encodingFamilies = [
+    {
+        // Windows code pages
+        encodings: [1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258],
+        convert: function(cp) {
+            return {
+                name: "windows-"+cp,
+                aliases: ["win"+cp, "cp"+cp, ""+cp],
+            }
+        }
+    },
+    {
+        // ISO-8859 code pages
+        encodings: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16],
+        convert: function(i) {
+            return {
+                name: "iso-8859-"+i,
+                aliases: ["cp"+(28590+i), (28590+i)],
+            }
+        }
+    },
+    {
+        // IBM/DOS code pages
+        encodings: [437, 737, 775, 850, 852, 855, 857, 858, 860, 861, 862, 863, 864, 865, 866, 869],
+        convert: function(cp) {
+            return {
+                name: "CP"+cp,
+                aliases: ["ibm"+cp, ""+cp],
+            }
+        }
+    },
+    {
+        // Macintosh code pages
+        encodings: ["macCroatian", "macCyrillic", "macGreek", 
+                    "macIceland", "macRoman", "macRomania", 
+                    "macThai", "macTurkish", "macUkraine"],
+    },
+    {
+        // KOI8 code pages
+        encodings: ["KOI8-R", "KOI8-U"],
+    },
+];
+
+
+var encodings = {
+    // Aliases.
+    "ascii8bit": "ascii",
+    "usascii": "ascii",
+
+    "latin1": "iso88591",
+    "latin2": "iso88592",
+    "latin3": "iso88593",
+    "latin4": "iso88594",
+    "latin6": "iso885910",
+    "latin7": "iso885913",
+    "latin8": "iso885914",
+    "latin9": "iso885915",
+    "latin10": "iso885916",
+
+    "cp819": "iso88951",
+    "arabic": "iso88596",
+    "arabic8": "iso88596",
+    "greek" : "iso88597",
+    "greek8" : "iso88597",
+    "hebrew": "iso88598",
+    "hebrew8": "iso88598",
+    "turkish": "iso88599",
+    "turkish8": "iso88599",
+    "thai": "iso885911",
+    "thai8": "iso885911",
+    "tis620": "iso885911",
+    "windows874": "iso885911",
+    "win874": "iso885911",
+    "cp874": "iso885911",
+    "874": "iso885911",
+    "celtic": "iso885914",
+    "celtic8": "iso885914",
+
+    "cp20866": "koi8r",
+    "20866": "koi8r",
+    "ibm878": "koi8r",
+    "cp21866": "koi8u",
+    "21866": "koi8u",
+    "ibm1168": "koi8u",
+    
+};
+
+// Add all encodings from encodingFamilies.
+encodingFamilies.forEach(function(family){
+    family.encodings.forEach(function(encoding){
+        if (family.convert)
+            encoding = family.convert(encoding);
+
+        var encodingIconvName = encoding.name ? encoding.name : encoding; 
+        var encodingName = encodingIconvName.replace(/[-_]/g, "").toLowerCase();
+
+        encodings[encodingName] = {
+            type: "singlebyte",
+            chars: generateCharsString(encodingIconvName)
+        };
+
+        if (encoding.aliases)
+            encoding.aliases.forEach(function(alias){
+                encodings[alias] = encodingName;
+            });
+    });
+});
+
+// Write encodings.
+fs.writeFileSync("encodings/singlebyte.js", 
+    "module.exports = " + JSON.stringify(encodings, undefined, "  ") + ";");
+
+
+function generateCharsString(encoding) {
+    console.log("Generate encoding for " + encoding);
+    var iconvToUtf8 = new Iconv(encoding, "UTF-8");
+    var chars = "";
+
+    for (var b = 0x80; b < 0x100; b++) {
+
+        try {
+            var convertedChar = iconvToUtf8.convert(new Buffer([b])).toString();
+            
+            if (convertedChar.length != 1)
+                throw new Error("Single-byte encoding error: Must return single char.");
+        } catch (exception) {
+            if (exception.code === "EILSEQ") {
+                convertedChar = "\ufffd";
+            } else {
+                throw exception;
+            }
+        }
+
+        chars += convertedChar;
+    }
+
+    return chars;
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..a55691b
--- /dev/null
+++ b/index.js
@@ -0,0 +1,231 @@
+var RE_SPACEDASH = /[- ]/g;
+// Module exports
+var iconv = module.exports = {
+    toEncoding: function(str, encoding) {
+        return iconv.getCodec(encoding).toEncoding(str);
+    },
+    fromEncoding: function(buf, encoding) {
+        return iconv.getCodec(encoding).fromEncoding(buf);
+    },
+    encodingExists: function(enc) {
+        loadEncodings();
+        enc = enc.replace(RE_SPACEDASH, "").toLowerCase();
+        return (iconv.encodings[enc] !== undefined);
+    },
+    
+    defaultCharUnicode: '�',
+    defaultCharSingleByte: '?',
+
+    encodingsLoaded: false,
+    
+    // Get correct codec for given encoding.
+    getCodec: function(encoding) {
+        loadEncodings();
+        var enc = encoding || "utf8";
+        var codecOptions = undefined;
+        while (1) {
+            if (getType(enc) === "String")
+                enc = enc.replace(RE_SPACEDASH, "").toLowerCase();
+            var codec = iconv.encodings[enc];
+            var type = getType(codec);
+            if (type === "String") {
+                // Link to other encoding.
+                codecOptions = {originalEncoding: enc};
+                enc = codec;
+            }
+            else if (type === "Object" && codec.type != undefined) {
+                // Options for other encoding.
+                codecOptions = codec;
+                enc = codec.type;
+            } 
+            else if (type === "Function")
+                // Codec itself.
+                return codec(codecOptions);
+            else
+                throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
+        }
+    },
+    
+    // Define basic encodings
+    encodings: {
+        internal: function(options) {
+            return {
+                toEncoding: toInternalEncoding,
+                fromEncoding: fromInternalEncoding,
+                options: options
+            };
+        },
+        utf8: "internal",
+        ucs2: "internal",
+        binary: "internal",
+        ascii: "internal",
+        base64: "internal",
+        
+        // Codepage single-byte encodings.
+        singlebyte: function(options) {
+            // Prepare chars if needed
+            if (!options.charsBuf) {
+                if (!options.chars || (options.chars.length !== 128 && options.chars.length !== 256))
+                    throw new Error("Encoding '"+options.type+"' has incorrect 'chars' (must be of len 128 or 256)");
+                
+                if (options.chars.length === 128)
+                    options.chars = asciiString + options.chars;
+
+                options.charsBuf = new Buffer(options.chars, 'ucs2');
+            }
+            
+            if (!options.revCharsBuf) {
+                options.revCharsBuf = new Buffer(65536);
+                var defChar = iconv.defaultCharSingleByte.charCodeAt(0);
+                for (var i = 0; i < options.revCharsBuf.length; i++)
+                    options.revCharsBuf[i] = defChar;
+                for (var i = 0; i < options.chars.length; i++)
+                    options.revCharsBuf[options.chars.charCodeAt(i)] = i;
+            }
+
+            return {
+                toEncoding: toSingleByteEncoding,
+                fromEncoding: fromSingleByteEncoding,
+                options: options,
+            };
+        },
+
+        // Codepage double-byte encodings.
+        table: function(options) {
+            if (!options.table) {
+                throw new Error("Encoding '" + options.type + "' has incorect 'table' option");
+            }
+            if (!options.revCharsTable) {
+                var revCharsTable = options.revCharsTable = {};
+                for (var i = 0; i <= 0xFFFF; i++) {
+                    revCharsTable[i] = 0;
+                }
+
+                var table = options.table;
+                for (var key in table) {
+                    revCharsTable[table[key]] = +key;
+                }
+            }
+            
+            return {
+                toEncoding: toTableEncoding,
+                fromEncoding: fromTableEncoding,
+                options: options,
+            };
+        }
+    }
+};
+
+function toInternalEncoding(str) {
+    return new Buffer(ensureString(str), this.options.originalEncoding);
+}
+
+function fromInternalEncoding(buf) {
+    return ensureBuffer(buf).toString(this.options.originalEncoding);
+}
+
+function toTableEncoding(str) {
+    str = ensureString(str);
+    var strLen = str.length;
+    var revCharsTable = this.options.revCharsTable;
+    var newBuf = new Buffer(strLen*2), gbkcode, unicode,
+        defaultChar = revCharsTable[iconv.defaultCharUnicode.charCodeAt(0)];
+
+    for (var i = 0, j = 0; i < strLen; i++) {
+        unicode = str.charCodeAt(i);
+        if (unicode >> 7) {
+            gbkcode = revCharsTable[unicode] || defaultChar;
+            newBuf[j++] = gbkcode >> 8; //high byte;
+            newBuf[j++] = gbkcode & 0xFF; //low byte
+        } else {//ascii
+            newBuf[j++] = unicode;
+        }
+    }
+    return newBuf.slice(0, j);
+}
+
+function fromTableEncoding(buf) {
+    buf = ensureBuffer(buf);
+    var bufLen = buf.length;
+    var table = this.options.table;
+    var newBuf = new Buffer(bufLen*2), unicode, gbkcode,
+        defaultChar = iconv.defaultCharUnicode.charCodeAt(0);
+
+    for (var i = 0, j = 0; i < bufLen; i++, j+=2) {
+        gbkcode = buf[i];
+        if (gbkcode & 0x80) {
+            gbkcode = (gbkcode << 8) + buf[++i];
+            unicode = table[gbkcode] || defaultChar;
+        } else {
+            unicode = gbkcode;
+        }
+        newBuf[j] = unicode & 0xFF; //low byte
+        newBuf[j+1] = unicode >> 8; //high byte
+    }
+    return newBuf.slice(0, j).toString('ucs2');
+}
+
+function toSingleByteEncoding(str) {
+    str = ensureString(str);
+    
+    var buf = new Buffer(str.length);
+    var revCharsBuf = this.options.revCharsBuf;
+    for (var i = 0; i < str.length; i++)
+        buf[i] = revCharsBuf[str.charCodeAt(i)];
+    
+    return buf;
+}
+
+function fromSingleByteEncoding(buf) {
+    buf = ensureBuffer(buf);
+    
+    // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
+    var charsBuf = this.options.charsBuf;
+    var newBuf = new Buffer(buf.length*2);
+    var idx1 = 0, idx2 = 0;
+    for (var i = 0, _len = buf.length; i < _len; i++) {
+        idx1 = buf[i]*2; idx2 = i*2;
+        newBuf[idx2] = charsBuf[idx1];
+        newBuf[idx2+1] = charsBuf[idx1+1];
+    }
+    return newBuf.toString('ucs2');
+}
+
+// Add aliases to convert functions
+iconv.encode = iconv.toEncoding;
+iconv.decode = iconv.fromEncoding;
+
+// Load other encodings manually from files in /encodings dir.
+function loadEncodings() {
+    if (!iconv.encodingsLoaded) {
+        [ require('./encodings/singlebyte'),
+          require('./encodings/gbk'),
+          require('./encodings/big5')
+        ].forEach(function(encodings) {
+            for (var key in encodings)
+                iconv.encodings[key] = encodings[key]
+        });
+        iconv.encodingsLoaded = true;
+    }
+}
+
+
+
+// Utilities
+var asciiString = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+              ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f';
+
+var ensureBuffer = function(buf) {
+    buf = buf || new Buffer(0);
+    return (buf instanceof Buffer) ? buf : new Buffer(""+buf, "binary");
+}
+
+var ensureString = function(str) {
+    str = str || "";
+    return (str instanceof Buffer) ? str.toString('utf8') : (""+str);
+}
+
+var getType = function(obj) {
+    return Object.prototype.toString.call(obj).slice(8, -1);
+}
+
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..ce08828
--- /dev/null
+++ b/package.json
@@ -0,0 +1,38 @@
+{
+    "name": "iconv-lite",
+    "description": "Convert character encodings in pure javascript.",
+    "version": "0.2.11",
+    "license": "MIT",
+    
+    "keywords": ["iconv", "convert", "charset"],
+    "author": "Alexander Shtuchkin <ashtuchkin at gmail.com>",
+    "contributors": [
+        "Jinwu Zhan (https://github.com/jenkinv)",
+        "Adamansky Anton (https://github.com/adamansky)",
+        "George Stagas (https://github.com/stagas)",
+        "Mike D Pilsbury (https://github.com/pekim)",
+        "Niggler (https://github.com/Niggler)",
+        "wychi (https://github.com/wychi)",
+        "David Kuo (https://github.com/david50407)",
+        "ChangZhuo Chen (https://github.com/czchen)",
+        "Lee Treveil (https://github.com/leetreveil)",
+        "Brian White (https://github.com/mscdex)"
+    ],
+    
+    "main": "index.js",
+    "homepage": "https://github.com/ashtuchkin/iconv-lite",
+    "repository": {
+        "type": "git",
+        "url": "git://github.com/ashtuchkin/iconv-lite.git"
+    },
+    "engines": {
+        "node": ">=0.4.0"
+    },
+    "scripts": {
+      "test": "vows --spec"
+    },
+    "devDependencies": {
+        "vows": "",
+        "iconv": ">=1.1"
+    }
+}
diff --git a/test/big5-test.js b/test/big5-test.js
new file mode 100644
index 0000000..f3fe1a8
--- /dev/null
+++ b/test/big5-test.js
@@ -0,0 +1,36 @@
+var vows    = require('vows'),
+    fs      = require('fs'),
+    assert  = require('assert'),
+    iconv   = require(__dirname + '/../');
+
+var testString = "中文abc", //unicode contains Big5-code and ascii
+    testStringBig5Buffer = new Buffer([0xa4,0xa4,0xa4,0xe5,0x61,0x62,0x63]),
+    testString2 = '測試',
+    testStringBig5Buffer2 = new Buffer([0xb4, 0xfa, 0xb8, 0xd5]);
+
+vows.describe("Big5 tests").addBatch({
+    "Big5 correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testString, "big5").toString('binary'), testStringBig5Buffer.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(testStringBig5Buffer, "big5"), testString);
+        assert.strictEqual(iconv.toEncoding(testString2, 'big5').toString('binary'), testStringBig5Buffer2.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(testStringBig5Buffer2, 'big5'), testString2);
+    },
+    "cp950 correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testString, "cp950").toString('binary'), testStringBig5Buffer.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(testStringBig5Buffer, "cp950"), testString);
+    },
+    "Big5 file read decoded,compare with iconv result": function() {
+        var contentBuffer = fs.readFileSync(__dirname+"/big5File.txt");
+        var str = iconv.fromEncoding(contentBuffer, "big5");
+        var iconvc = new (require('iconv').Iconv)('big5','utf8');
+        assert.strictEqual(iconvc.convert(contentBuffer).toString(), str);
+    },
+    "Big5 correctly decodes and encodes characters · and ×": function() {
+        // https://github.com/ashtuchkin/iconv-lite/issues/13
+        // Reference: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT
+        var chars = "·×";
+        var big5Chars = new Buffer([0xA1, 0x50, 0xA1, 0xD1]);
+        assert.strictEqual(iconv.toEncoding(chars, "big5").toString('binary'), big5Chars.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(big5Chars, "big5"), chars)
+    },
+}).export(module)
diff --git a/test/big5File.txt b/test/big5File.txt
new file mode 100644
index 0000000..9c13042
--- /dev/null
+++ b/test/big5File.txt
@@ -0,0 +1,13 @@
+<HTML>
+<HEAD>    
+	<TITLE> meta ���Ҫ��ϥΡG����� </TITLE>
+	<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
+</HEAD>
+<BODY>
+
+�o�O�@���c�餤����I<br>
+(This page uses big5 character set.)<br>
+charset=big5
+
+</BODY>
+</HTML>
\ No newline at end of file
diff --git a/test/cyrillic-test.js b/test/cyrillic-test.js
new file mode 100644
index 0000000..259d283
--- /dev/null
+++ b/test/cyrillic-test.js
@@ -0,0 +1,86 @@
+var vows = require('vows'),
+    assert = require('assert'),
+    iconv = require(__dirname+'/../');
+
+var baseStrings = {
+    empty: "",
+    hi: "Привет!",
+    ascii: '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+           ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f',
+    rus: "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя",
+    additional1: "ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—™љ›њќћџ ЎўЈ¤Ґ¦§Ё©Є«¬\xAD®Ї°±Ііґµ¶·ё№є»јЅѕї",
+    additional2: "─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷═║╒ё╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡Ё╢╣╤╥╦╧╨╩╪╫╬©",
+    additional3: " ЁЂЃЄЅІЇЈЉЊЋЌ­ЎЏ№ёђѓєѕіїјљњћќ§ўџ",
+    untranslatable: "£Åçþÿ¿",
+};
+
+var encodings = [{
+    name: "Win-1251",
+    variations: ['win1251', 'Windows-1251', 'windows1251', 'CP1251', 1251],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\xcf\xf0\xe8\xe2\xe5\xf2!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        rus: new Buffer('\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
+        additional1: new Buffer('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf','binary'),
+    }
+}, {
+    name: "Koi8-R",
+    variations: ['koi8r', 'KOI8-R', 'cp20866', 20866],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\xf0\xd2\xc9\xd7\xc5\xd4!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        rus: new Buffer('\xe1\xe2\xf7\xe7\xe4\xe5\xf6\xfa\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf2\xf3\xf4\xf5\xe6\xe8\xe3\xfe\xfb\xfd\xff\xf9\xf8\xfc\xe0\xf1\xc1\xc2\xd7\xc7\xc4\xc5\xd6\xda\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd2\xd3\xd4\xd5\xc6\xc8\xc3\xde\xdb\xdd\xdf\xd9\xd8\xdc\xc0\xd1', 'binary'),
+        additional2: new Buffer('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf', 'binary'),
+    }
+}, {
+    name: "ISO 8859-5",
+    variations: ['iso88595', 'ISO-8859-5', 'ISO 8859-5', 'cp28595', 28595],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\xbf\xe0\xd8\xd2\xd5\xe2!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        rus: new Buffer('\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef', 'binary'),
+        additional3: new Buffer('\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
+    }
+}];
+
+var testsBatch = {};
+encodings.forEach(function(encoding) {
+    var enc = encoding.variations[0];
+    var key = "hi";
+    var tests = {
+        "Convert to empty buffer": function() {
+            assert.strictEqual(iconv.toEncoding("", enc).toString('binary'), new Buffer('').toString('binary'));
+        },
+        "Convert from empty buffer": function() {
+            assert.strictEqual(iconv.fromEncoding(new Buffer(''), enc), "");
+        },
+        "Convert from buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc), 
+                    baseStrings[key]);
+        },
+        "Convert to buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.toEncoding(baseStrings[key], enc).toString('binary'), 
+                    encoding.encodedStrings[key].toString('binary'));
+        },
+        "Try different variations of encoding": function() {
+            encoding.variations.forEach(function(enc) {
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc), baseStrings[key]);
+                assert.strictEqual(iconv.toEncoding(baseStrings[key], enc).toString('binary'), encoding.encodedStrings[key].toString('binary'));
+            });
+        },
+        "Untranslatable chars are converted to defaultCharSingleByte": function() {
+            var expected = baseStrings.untranslatable.split('').map(function(c) {return iconv.defaultCharSingleByte; }).join('');
+            assert.strictEqual(iconv.toEncoding(baseStrings.untranslatable, enc).toString('binary'), expected); // Only '?' characters.
+        }
+    };
+    
+    testsBatch[encoding.name+":"] = tests;
+});
+
+vows.describe("Test Cyrillic encodings").addBatch(testsBatch).export(module);
+
diff --git a/test/gbk-test.js b/test/gbk-test.js
new file mode 100644
index 0000000..7b2e47b
--- /dev/null
+++ b/test/gbk-test.js
@@ -0,0 +1,38 @@
+var vows    = require('vows'),
+    fs      = require('fs'),
+    assert  = require('assert'),
+    iconv   = require(__dirname+'/../');
+
+var testString = "中国abc",//unicode contains GBK-code and ascii
+    testStringGBKBuffer = new Buffer([0xd6,0xd0,0xb9,0xfa,0x61,0x62,0x63]);
+
+vows.describe("GBK tests").addBatch({
+    "Vows is working": function() {},
+    "Return values are of correct types": function() {
+        assert.ok(iconv.toEncoding(testString, "utf8") instanceof Buffer);        
+        var s = iconv.fromEncoding(new Buffer(testString), "utf8");
+        assert.strictEqual(Object.prototype.toString.call(s), "[object String]");
+    },
+    "GBK correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testString, "GBK").toString('binary'), testStringGBKBuffer.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(testStringGBKBuffer, "GBK"), testString);
+    },
+    "GB2312 correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testString, "GB2312").toString('binary'), testStringGBKBuffer.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(testStringGBKBuffer, "GB2312"), testString);
+    },
+    "GBK file read decoded,compare with iconv result": function() {
+        var contentBuffer = fs.readFileSync(__dirname+"/gbkFile.txt");
+        var str = iconv.fromEncoding(contentBuffer, "GBK");
+        var iconvc = new (require('iconv').Iconv)('GBK','utf8');
+        assert.strictEqual(iconvc.convert(contentBuffer).toString(), str);
+    },
+    "GBK correctly decodes and encodes characters · and ×": function() {
+        // https://github.com/ashtuchkin/iconv-lite/issues/13
+        // Reference: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
+        var chars = "·×";
+        var gbkChars = new Buffer([0xA1, 0xA4, 0xA1, 0xC1]);
+        assert.strictEqual(iconv.toEncoding(chars, "GBK").toString('binary'), gbkChars.toString('binary'));
+        assert.strictEqual(iconv.fromEncoding(gbkChars, "GBK"), chars)
+    },
+}).export(module)
diff --git a/test/gbkFile.txt b/test/gbkFile.txt
new file mode 100644
index 0000000..345b5d0
--- /dev/null
+++ b/test/gbkFile.txt
@@ -0,0 +1,14 @@
+<!doctype html><html><head><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><title>�ٶ�һ�£����֪��      </title><style>html{overflow-y:auto}body{font:12px arial;text-align:center;background:#fff}body,p,form,ul,li{margin:0;padding:0;list-style:none}body,form,#fm{position:relative}td{text-align:left}img{border:0}a{color:#00c}a:active{color:#f60}#u{padding:7px 10px 3px 0;text-align:right}#m{width:680px;margin:0 auto}#nv{font-size:16px;margin:0 0 4px;text-align:left;text-inde [...]
+</head>
+
+<body><div id="u"><a href="http://www.baidu.com/gaoji/preferences.html" name="tj_setting">��������</a> | <a href="http://passport.baidu.com/?login&tpl=mn" name="tj_login">��¼</a></div>
+<div id="m"><p id="lg"><img src="http://www.baidu.com/img/baidu_sylogo1.gif" width="270" height="129" usemap="#mp"><map name="mp"><area shape="rect" coords="40,25,230,95" href="http://hi.baidu.com/baidu/" target="_blank" title="��˽��� �ٶȵĿռ�" ></map></p><p id="nv"><a href="http://news.baidu.com">�� ��</a>��<b>�� ҳ</b>��<a href="http://tieba.baidu.com">�� ��</a>��<a href="http://zhidao.baidu.com">֪ ��</a>��<a href="http://mp3.baidu.com">MP3</a>��<a href="http://image.b [...]
+<p id="lk"><a href="http://hi.baidu.com">�ռ�</a>��<a href="http://baike.baidu.com">�ٿ�</a>��<a href="http://www.hao123.com">hao123</a><span> | <a href="/more/">����>></a></span></p><p id="lm"></p><p><a id="seth" onClick="this.setHomePage('http://www.baidu.com')" href="http://utility.baidu.com/traf/click.php?id=215&url=http://www.baidu.com" onmousedown="return ns_c({'fm':'behs','tab':'homepage','pos':0})">�Ѱٶ���Ϊ��ҳ</a><a id="setf" onClick="fa(this)" href="javascript:void(0)" onmous [...]
+<p id="lh"><a href="http://e.baidu.com/?refer=888">����ٶ��ƹ�</a> | <a href="http://top.baidu.com">�������ư�</a> | <a href="http://home.baidu.com">���ڰٶ�</a> | <a href="http://ir.baidu.com">About Baidu</a></p><p id="cp">©2011 Baidu <a href="/duty/">ʹ�ðٶ�ǰ�ض�</a> <a href="http://www.miibeian.gov.cn" target="_blank">��ICP֤030173��</a> <img src="http://gimg.baidu.com/img/gs.gif"></p></div></body>
+
+<script>var w=window,d=document,n=navigator,k=d.f.wd,a=d.getElementById("nv").getElementsByTagName("a"),isIE=n.userAgent.indexOf("MSIE")!=-1&&!window.opera;for(var i=0;i<a.length;i++){a[i].onclick=function(){if(k.value.length>0){var C=this,A=C.href,B=encodeURIComponent(k.value);if(A.indexOf("q=")!=-1){C.href=A.replace(/q=[^&\x24]*/,"q="+B)}else{this.href+="?q="+B}}}}(function(){if(/q=([^&]+)/.test(location.search)){k.value=decodeURIComponent(RegExp["\x241"])}})();if(n.cookieEnabled&&!/su [...]
+
+
+<script type="text/javascript" src="http://www.baidu.com/cache/hps/js/hps-1.2.js"></script>
+
+</html><!--b762345d979562e8-->
\ No newline at end of file
diff --git a/test/greek-test.js b/test/greek-test.js
new file mode 100644
index 0000000..0394ee6
--- /dev/null
+++ b/test/greek-test.js
@@ -0,0 +1,79 @@
+var vows = require('vows'),
+    assert = require('assert'),
+    iconv = require(__dirname+'/../');
+
+var baseStrings = {
+    empty: "",
+    hi: "Γειά!",
+    ascii: '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+           ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f',
+    greek: "αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩάέήίόύώΆΈΉΊΌΎΏϊϋΪΫ",
+    untranslatable: "Åçþÿ¿"
+};
+
+var encodings = [{
+    name: "windows1253",
+    variations: ['windows-1253', 'win-1253', 'win1253', 'cp1253', 'cp-1253', 1253],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\xc3\xe5\xe9\xdc!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        greek: new Buffer('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xa2\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
+    }
+}, {
+    name: "iso88597",
+    variations: ['iso-8859-7', 'greek', 'greek8', 'cp28597', 'cp-28597', 28597],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\xc3\xe5\xe9\xdc!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        greek: new Buffer('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xb6\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
+    }
+}, {
+    name: "cp737",
+    variations: ['cp-737', 737],
+    encodedStrings: {
+        empty: new Buffer(''),
+        hi: new Buffer('\x82\x9c\xa0\xe1!', 'binary'),
+        ascii: new Buffer(baseStrings.ascii, 'binary'),
+        greek: new Buffer('\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xab\xac\xad\xae\xaf\xe0\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\xe1\xe2\xe3\xe5\xe6\xe7\xe9\xea\xeb\xec\xed\xee\xef\xf0\xe4\xe8\xf4\xf5', 'binary'),
+    }
+}];
+
+var testsBatch = {};
+encodings.forEach(function(encoding) {
+    var enc = encoding.variations[0];
+    var key = "hi";
+    var tests = {
+        "Convert to empty buffer": function() {
+            assert.strictEqual(iconv.toEncoding("", enc).toString('binary'), new Buffer('').toString('binary'));
+        },
+        "Convert from empty buffer": function() {
+            assert.strictEqual(iconv.fromEncoding(new Buffer(''), enc), "");
+        },
+        "Convert from buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc), 
+                    baseStrings[key]);
+        },
+        "Convert to buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.toEncoding(baseStrings[key], enc).toString('binary'), 
+                    encoding.encodedStrings[key].toString('binary'));
+        },
+        "Try different variations of encoding": function() {
+            encoding.variations.forEach(function(enc) {
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc), baseStrings[key]);
+                assert.strictEqual(iconv.toEncoding(baseStrings[key], enc).toString('binary'), encoding.encodedStrings[key].toString('binary'));
+            });
+        },
+        "Untranslatable chars are converted to defaultCharSingleByte": function() {
+            var expected = baseStrings.untranslatable.split('').map(function(c) {return iconv.defaultCharSingleByte; }).join('');
+            assert.strictEqual(iconv.toEncoding(baseStrings.untranslatable, enc).toString('binary'), expected); // Only '?' characters.
+        }
+    };
+    
+    testsBatch[encoding.name+":"] = tests;
+});
+
+vows.describe("Test Greek encodings").addBatch(testsBatch).export(module);
diff --git a/test/main-test.js b/test/main-test.js
new file mode 100644
index 0000000..50177f2
--- /dev/null
+++ b/test/main-test.js
@@ -0,0 +1,55 @@
+var vows = require('vows'),
+    assert = require('assert'),
+    iconv = require(__dirname+'/../');
+
+var testString = "Hello123!";
+var testStringLatin1 = "Hello123!£Å÷×çþÿ¿®";
+var testStringBase64 = "SGVsbG8xMjMh";
+
+vows.describe("Generic UTF8-UCS2 tests").addBatch({
+    "Vows is working": function() {},
+    "Return values are of correct types": function() {
+        assert.ok(iconv.toEncoding(testString, "utf8") instanceof Buffer);
+        
+        var s = iconv.fromEncoding(new Buffer(testString), "utf8");
+        assert.strictEqual(Object.prototype.toString.call(s), "[object String]");
+    },
+    "Internal encodings all correctly encoded/decoded": function() {
+        ['utf8', "UTF-8", "UCS2", "binary", ""].forEach(function(enc) {
+            assert.strictEqual(iconv.toEncoding(testStringLatin1, enc).toString(enc), testStringLatin1);
+            assert.strictEqual(iconv.fromEncoding(new Buffer(testStringLatin1, enc), enc), testStringLatin1);
+        });
+    },
+    "Base64 correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testStringBase64, "base64").toString("binary"), testString);
+        assert.strictEqual(iconv.fromEncoding(new Buffer(testString, "binary"), "base64"), testStringBase64);
+    },
+    "Latin1 correctly encoded/decoded": function() {    
+        assert.strictEqual(iconv.toEncoding(testStringLatin1, "latin1").toString("binary"), testStringLatin1);
+        assert.strictEqual(iconv.fromEncoding(new Buffer(testStringLatin1, "binary"), "latin1"), 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"));
+        assert.ok(res instanceof Buffer);
+        assert.strictEqual(res.toString("utf8"), testStringLatin1);
+    },
+    "Throws on unknown encodings": function() {
+        assert.throws(function() { iconv.toEncoding("a", "xxx"); });
+        assert.throws(function() { iconv.fromEncoding("a", "xxx"); });
+    },
+    "Convert non-strings and non-buffers": function() {
+        assert.strictEqual(iconv.toEncoding({}, "utf8").toString(), "[object Object]");
+        assert.strictEqual(iconv.toEncoding(10, "utf8").toString(), "10");
+        assert.strictEqual(iconv.toEncoding(undefined, "utf8").toString(), "");
+        assert.strictEqual(iconv.fromEncoding({}, "utf8"), "[object Object]");
+        assert.strictEqual(iconv.fromEncoding(10, "utf8"), "10");
+        assert.strictEqual(iconv.fromEncoding(undefined, "utf8"), "");
+    },
+    "Aliases encode and decode work the same as toEncoding and fromEncoding": function() {
+        assert.strictEqual(iconv.toEncoding(testString, "latin1").toString("binary"), iconv.encode(testString, "latin1").toString("binary"));
+        assert.strictEqual(iconv.fromEncoding(testStringLatin1, "latin1"), iconv.decode(testStringLatin1, "latin1"));
+    },
+}).export(module)
diff --git a/test/performance.js b/test/performance.js
new file mode 100644
index 0000000..835deac
--- /dev/null
+++ b/test/performance.js
@@ -0,0 +1,67 @@
+
+var iconv = require('iconv');
+var iconv_lite = require("../index");
+
+var encoding = process.argv[2] || "windows-1251";
+var convertTimes = 10000;
+
+var encodingStrings = {
+    'windows-1251': 'This is a test string 32 chars..',
+    'gbk':          '这是中文字符测试。。!@¥%12',
+    'utf8': '这是中文字符测试。。!@¥%12This is a test string 48 chars..',
+};
+// Test encoding.
+var str = encodingStrings[encoding];
+if (!str) {
+    throw new Error('Don\'t support ' + encoding + ' performance test.');
+}
+for (var i = 0; i < 13; i++) {
+    str = str + str;
+}
+
+console.log('\n' + encoding + ' charset performance test:');
+console.log("\nEncoding "+str.length+" chars "+convertTimes+" times:");
+
+var start = Date.now();
+var converter = new iconv.Iconv("utf8", encoding);
+for (var i = 0; i < convertTimes; i++) {
+    var b = converter.convert(str);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*b.length/duration/1024;
+
+console.log("iconv: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+var start = Date.now();
+for (var i = 0; i < convertTimes; i++) {
+    var b = iconv_lite.encode(str, encoding);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*b.length/duration/1024;
+
+console.log("iconv-lite: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+
+// Test decoding.
+var buf = iconv_lite.encode(str, encoding);
+console.log("\nDecoding "+buf.length+" bytes "+convertTimes+" times:");
+
+var start = Date.now();
+var converter = new iconv.Iconv(encoding, "utf8");
+for (var i = 0; i < convertTimes; i++) {
+    var s = converter.convert(buf).toString();
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*buf.length/duration/1024;
+
+console.log("iconv: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+var start = Date.now();
+for (var i = 0; i < convertTimes; i++) {
+    var s = iconv_lite.decode(buf, encoding);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*buf.length/duration/1024;
+
+console.log("iconv-lite: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
diff --git a/test/turkish-test.js b/test/turkish-test.js
new file mode 100644
index 0000000..b2eb68e
--- /dev/null
+++ b/test/turkish-test.js
@@ -0,0 +1,90 @@
+var vows = require('vows'),
+    assert = require('assert'),
+    iconv = require(__dirname+'/../');
+
+var ascii = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
+           ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f';
+
+var encodings = [{
+    name: "windows1254",
+    variations: ['windows-1254', 'win-1254', 'win1254', 'cp1254', 'cp-1254', 1254],
+    strings: {
+        empty: "",
+        ascii: ascii,
+        turkish: "€‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ",
+        untranslatable: "\x81\x8d\x8e\x8f\x90\x9d\x9e"
+    },
+    encodedStrings: {
+        empty: new Buffer(''),
+        ascii: new Buffer(ascii, 'binary'),
+        turkish: new Buffer(
+            '\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c' +
+            '\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9f' +
+            '\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf' +
+            '\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf' +
+            '\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf' +
+            '\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf' +
+            '\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef' +
+            '\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff',
+            'binary'),
+    }
+}, {
+    name: "iso88599",
+    variations: ['iso-8859-9', 'turkish', 'turkish8', 'cp28599', 'cp-28599', 28599],
+    strings: {
+        empty: "",
+        ascii: ascii,
+        turkish: "\xa0¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ",
+        untranslatable: ''
+    },
+    encodedStrings: {
+        empty: new Buffer(''),
+        ascii: new Buffer(ascii, 'binary'),
+        turkish: new Buffer(
+            '\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf' +
+            '\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf' +
+            '\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf' +
+            '\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf' +
+            '\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef' +
+            '\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff',
+             'binary')
+    }
+}];
+
+var testsBatch = {};
+encodings.forEach(function(encoding) {
+    var enc = encoding.variations[0];
+    var key = "turkish";
+    var tests = {
+        "Convert to empty buffer": function() {
+            assert.strictEqual(iconv.toEncoding("", enc).toString('binary'), new Buffer('').toString('binary'));
+        },
+        "Convert from empty buffer": function() {
+            assert.strictEqual(iconv.fromEncoding(new Buffer(''), enc), "");
+        },
+        "Convert from buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc),
+                    encoding.strings[key]);
+        },
+        "Convert to buffer": function() {
+            for (var key in encoding.encodedStrings)
+                assert.strictEqual(iconv.toEncoding(encoding.strings[key], enc).toString('binary'),
+                    encoding.encodedStrings[key].toString('binary'));
+        },
+        "Try different variations of encoding": function() {
+            encoding.variations.forEach(function(enc) {
+                assert.strictEqual(iconv.fromEncoding(encoding.encodedStrings[key], enc), encoding.strings[key]);
+                assert.strictEqual(iconv.toEncoding(encoding.strings[key], enc).toString('binary'), encoding.encodedStrings[key].toString('binary'));
+            });
+        },
+        "Untranslatable chars are converted to defaultCharSingleByte": function() {
+            var expected = encoding.strings.untranslatable.split('').map(function(c) {return iconv.defaultCharSingleByte; }).join('');
+            assert.strictEqual(iconv.toEncoding(encoding.strings.untranslatable, enc).toString('binary'), expected); // Only '?' characters.
+        }
+    };
+
+    testsBatch[encoding.name+":"] = tests;
+});
+
+vows.describe("Test Turkish encodings").addBatch(testsBatch).export(module);

-- 
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