version bump 1.1.0: cputils guard unknown codepage

This commit is contained in:
SheetJS 2014-05-24 22:59:07 -07:00
parent 6d849693b7
commit b501434a20
32 changed files with 171 additions and 51 deletions

View File

@ -68,6 +68,17 @@ and returns a representation controlled by `ofmt`:
- If `ofmt == 'str'`, return a String where `o.charCodeAt(i)` is the ith byte
- If `ofmt == 'arr'`, return an Array of bytes
## Known Excel Codepages
A much smaller script, including only the codepages known to be used in Excel,
is available under the name `cpexcel`. It exposes the same variable `cptable`
and is suitable as a drop-in replacement when the full codepage tables are not
needed.
In node:
var cptable = require('codepage/dist/cpexcel.full');
## Building the script
This script uses [voc](npm.im/voc). The script to build the codepage tables and

View File

@ -478,7 +478,7 @@ describe('consistency', function() {
cptable = require('./');
U = cptable.utils;
var chk = function(cptable, cacheit) { return function(x) {
it('should consistently process CP ' + x, function() {
it('should consistently process CP ' + x + ' ' + cacheit, function() {
var cp = cptable[x], D = cp.dec, E = cp.enc;
if(cacheit) cptable.utils.cache.encache();
else cptable.utils.cache.decache();
@ -704,7 +704,7 @@ describe('failures', function() {
```json>package.json
{
"name": "codepage",
"version": "1.0.0",
"version": "1.1.0",
"author": "SheetJS",
"description": "pure-JS library to handle codepages",
"keywords": [ "codepage", "iconv", "convert", "strings" ],
@ -727,7 +727,7 @@ describe('failures', function() {
},
"config": {
"blanket": {
"pattern": "[cptable.js,cputils.js]"
"pattern": "[cptable.js,cputils.js,cpexcel.js]"
}
},
"bugs": { "url": "https://github.com/SheetJS/js-codepage/issues" },

View File

@ -161,10 +161,12 @@
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ describe('README', function() {
describe('consistency', function() {
U = cptable.utils;
var chk = function(cptable, cacheit) { return function(x) {
it('should consistently process CP ' + x, function() {
it('should consistently process CP ' + x + ' ' + cacheit, function() {
var cp = cptable[x], D = cp.dec, E = cp.enc;
if(cacheit) cptable.utils.cache.encache();
else cptable.utils.cache.decache();

View File

@ -959,10 +959,12 @@ if (typeof module !== 'undefined' && module.exports) module.exports = cptable;
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});

View File

@ -6499,10 +6499,12 @@ if (typeof module !== 'undefined' && module.exports) module.exports = cptable;
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});

2
dist/cputils.js vendored
View File

@ -161,10 +161,12 @@
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});

2
dist/sbcs.full.js vendored
View File

@ -263,10 +263,12 @@ if (typeof module !== 'undefined' && module.exports) module.exports = cptable;
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});

View File

@ -11,11 +11,19 @@ which codepages are used.
## Setup
In node:
var cptable = require('codepage');
In the browser:
<script src="cptable.js"></script>
<script src="cputils.js"></script>
Alternatively, use the full version in the dist folder:
<script src="cptable.full.js"></script>
The complete set of codepages is large due to some Double Byte Character Set
encodings. A much smaller file that just includes SBCS codepages is provided in
this repo (`sbcs.js`), as well as a file for other projects (`cpexcel.js`)
@ -37,10 +45,6 @@ the object, edit the `JSVAR` shell variable in `make.sh` and run the script.
The utilities functions are contained in `cputils.js`, which assumes that the
appropriate codepage scripts were loaded.
In node:
var cptable = require('codepage');
## Usage
The codepages are indexed by number. To get the unicode character for a given
@ -64,6 +68,17 @@ and returns a representation controlled by `ofmt`:
- If `ofmt == 'str'`, return a String where `o.charCodeAt(i)` is the ith byte
- If `ofmt == 'arr'`, return an Array of bytes
## Known Excel Codepages
A much smaller script, including only the codepages known to be used in Excel,
is available under the name `cpexcel`. It exposes the same variable `cptable`
and is suitable as a drop-in replacement when the full codepage tables are not
needed.
In node:
var cptable = require('codepage/dist/cpexcel.full');
## Building the script
This script uses [voc](npm.im/voc). The script to build the codepage tables and

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,11 +11,19 @@ which codepages are used.
+ACMAIw Setup
In node:
var cptable +AD0 require('codepage')+ADs
In the browser:
+ADw-script src+AD0AIg-cptable.js+ACIAPgA8-/script+AD4
+ADw-script src+AD0AIg-cputils.js+ACIAPgA8-/script+AD4
Alternatively, use the full version in the dist folder:
+ADw-script src+AD0AIg-cptable.full.js+ACIAPgA8-/script+AD4
The complete set of codepages is large due to some Double Byte Character Set
encodings. A much smaller file that just includes SBCS codepages is provided in
this repo (+AGA-sbcs.js+AGA), as well as a file for other projects (+AGA-cpexcel.js+AGA)
@ -37,10 +45,6 @@ the object, edit the +AGA-JSVAR+AGA shell variable in +AGA-make.sh+AGA and run t
The utilities functions are contained in +AGA-cputils.js+AGA, which assumes that the
appropriate codepage scripts were loaded.
In node:
var cptable +AD0 require('codepage')+ADs
+ACMAIw Usage
The codepages are indexed by number. To get the unicode character for a given
@ -64,6 +68,17 @@ and returns a representation controlled by +AGA-ofmt+AGA:
- If +AGA-ofmt +AD0APQ 'str'+AGA, return a String where +AGA-o.charCodeAt(i)+AGA is the ith byte
- If +AGA-ofmt +AD0APQ 'arr'+AGA, return an Array of bytes
+ACMAIw Known Excel Codepages
A much smaller script, including only the codepages known to be used in Excel,
is available under the name +AGA-cpexcel+AGA. It exposes the same variable +AGA-cptable+AGA
and is suitable as a drop-in replacement when the full codepage tables are not
needed.
In node:
var cptable +AD0 require('codepage/dist/cpexcel.full')+ADs
+ACMAIw Building the script
This script uses +AFs-voc+AF0(npm.im/voc). The script to build the codepage tables and

View File

@ -11,11 +11,19 @@ which codepages are used.
## Setup
In node:
var cptable = require('codepage');
In the browser:
<script src="cptable.js"></script>
<script src="cputils.js"></script>
Alternatively, use the full version in the dist folder:
<script src="cptable.full.js"></script>
The complete set of codepages is large due to some Double Byte Character Set
encodings. A much smaller file that just includes SBCS codepages is provided in
this repo (`sbcs.js`), as well as a file for other projects (`cpexcel.js`)
@ -37,10 +45,6 @@ the object, edit the `JSVAR` shell variable in `make.sh` and run the script.
The utilities functions are contained in `cputils.js`, which assumes that the
appropriate codepage scripts were loaded.
In node:
var cptable = require('codepage');
## Usage
The codepages are indexed by number. To get the unicode character for a given
@ -64,6 +68,17 @@ and returns a representation controlled by `ofmt`:
- If `ofmt == 'str'`, return a String where `o.charCodeAt(i)` is the ith byte
- If `ofmt == 'arr'`, return an Array of bytes
## Known Excel Codepages
A much smaller script, including only the codepages known to be used in Excel,
is available under the name `cpexcel`. It exposes the same variable `cptable`
and is suitable as a drop-in replacement when the full codepage tables are not
needed.
In node:
var cptable = require('codepage/dist/cpexcel.full');
## Building the script
This script uses [voc](npm.im/voc). The script to build the codepage tables and

View File

@ -478,7 +478,7 @@ describe('consistency', function() {
cptable = require('./');
U = cptable.utils;
var chk = function(cptable, cacheit) { return function(x) {
it('should consistently process CP ' + x, function() {
it('should consistently process CP ' + x + ' ' + cacheit, function() {
var cp = cptable[x], D = cp.dec, E = cp.enc;
if(cacheit) cptable.utils.cache.encache();
else cptable.utils.cache.decache();
@ -704,16 +704,32 @@ describe('failures', function() {
```json>package.json
{
"name": "codepage",
"version": "0.6.0",
"version": "1.1.0",
"author": "SheetJS",
"description": "pure-JS library to handle codepages",
"keywords": [ "codepage", "iconv", "convert", "strings" ],
"bin": {
"codepage": "./bin/codepage.njs"
},
"main": "cputils.js",
"dependencies": { "voc":"" },
"devDependencies": { "mocha":"" },
"scripts": { "build": "make js", "test": "make test" },
"repository": {"type":"git","url":"git://github.com/SheetJS/js-codepage.git"},
"config": { "blanket": { "pattern": "[cptable.js,cputils.js]" } },
"dependencies": {
"voc":"",
"commander":""
},
"devDependencies": {
"mocha":""
},
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-codepage.git"},
"scripts": {
"pretest": "git submodule init && git submodule update",
"test": "make test",
"build": "make js"
},
"config": {
"blanket": {
"pattern": "[cptable.js,cputils.js,cpexcel.js]"
}
},
"bugs": { "url": "https://github.com/SheetJS/js-codepage/issues" },
"license": "Apache-2.0",
"engines": { "node": ">=0.8" }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -478,7 +478,7 @@ describe('consistency', function() +AHs
cptable +AD0 require('./')+ADs
U +AD0 cptable.utils+ADs
var chk +AD0 function(cptable, cacheit) +AHs return function(x) +AHs
it('should consistently process CP ' +- x, function() +AHs
it('should consistently process CP ' +- x +- ' ' +- cacheit, function() +AHs
var cp +AD0 cptable+AFs-x+AF0, D +AD0 cp.dec, E +AD0 cp.enc+ADs
if(cacheit) cptable.utils.cache.encache()+ADs
else cptable.utils.cache.decache()+ADs
@ -704,16 +704,32 @@ describe('failures', function() +AHs
+AGAAYABg-json+AD4-package.json
+AHs
+ACI-name+ACI: +ACI-codepage+ACI,
+ACI-version+ACI: +ACI-0.6.0+ACI,
+ACI-version+ACI: +ACI-1.1.0+ACI,
+ACI-author+ACI: +ACI-SheetJS+ACI,
+ACI-description+ACI: +ACI-pure-JS library to handle codepages+ACI,
+ACI-keywords+ACI: +AFs +ACI-codepage+ACI, +ACI-iconv+ACI, +ACI-convert+ACI, +ACI-strings+ACI +AF0,
+ACI-bin+ACI: +AHs
+ACI-codepage+ACI: +ACI./bin/codepage.njs+ACI
+AH0,
+ACI-main+ACI: +ACI-cputils.js+ACI,
+ACI-dependencies+ACI: +AHs +ACI-voc+ACI:+ACIAIg +AH0,
+ACI-devDependencies+ACI: +AHs +ACI-mocha+ACI:+ACIAIg +AH0,
+ACI-scripts+ACI: +AHs +ACI-build+ACI: +ACI-make js+ACI, +ACI-test+ACI: +ACI-make test+ACI +AH0,
+ACI-repository+ACI: +AHsAIg-type+ACI:+ACI-git+ACI,+ACI-url+ACI:+ACI-git://github.com/SheetJS/js-codepage.git+ACIAfQ,
+ACI-config+ACI: +AHs +ACI-blanket+ACI: +AHs +ACI-pattern+ACI: +ACIAWw-cptable.js,cputils.js+AF0AIg +AH0 +AH0,
+ACI-dependencies+ACI: +AHs
+ACI-voc+ACI:+ACIAIg,
+ACI-commander+ACI:+ACIAIg
+AH0,
+ACI-devDependencies+ACI: +AHs
+ACI-mocha+ACI:+ACIAIg
+AH0,
+ACI-repository+ACI: +AHs +ACI-type+ACI:+ACI-git+ACI, +ACI-url+ACI:+ACI-git://github.com/SheetJS/js-codepage.git+ACIAfQ,
+ACI-scripts+ACI: +AHs
+ACI-pretest+ACI: +ACI-git submodule init +ACYAJg git submodule update+ACI,
+ACI-test+ACI: +ACI-make test+ACI,
+ACI-build+ACI: +ACI-make js+ACI
+AH0,
+ACI-config+ACI: +AHs
+ACI-blanket+ACI: +AHs
+ACI-pattern+ACI: +ACIAWw-cptable.js,cputils.js,cpexcel.js+AF0AIg
+AH0
+AH0,
+ACI-bugs+ACI: +AHs +ACI-url+ACI: +ACI-https://github.com/SheetJS/js-codepage/issues+ACI +AH0,
+ACI-license+ACI: +ACI-Apache-2.0+ACI,
+ACI-engines+ACI: +AHs +ACI-node+ACI: +ACIAPgA9-0.8+ACI +AH0

View File

@ -478,7 +478,7 @@ describe('consistency', function() {
cptable = require('./');
U = cptable.utils;
var chk = function(cptable, cacheit) { return function(x) {
it('should consistently process CP ' + x, function() {
it('should consistently process CP ' + x + ' ' + cacheit, function() {
var cp = cptable[x], D = cp.dec, E = cp.enc;
if(cacheit) cptable.utils.cache.encache();
else cptable.utils.cache.decache();
@ -704,16 +704,32 @@ describe('failures', function() {
```json>package.json
{
"name": "codepage",
"version": "0.6.0",
"version": "1.1.0",
"author": "SheetJS",
"description": "pure-JS library to handle codepages",
"keywords": [ "codepage", "iconv", "convert", "strings" ],
"bin": {
"codepage": "./bin/codepage.njs"
},
"main": "cputils.js",
"dependencies": { "voc":"" },
"devDependencies": { "mocha":"" },
"scripts": { "build": "make js", "test": "make test" },
"repository": {"type":"git","url":"git://github.com/SheetJS/js-codepage.git"},
"config": { "blanket": { "pattern": "[cptable.js,cputils.js]" } },
"dependencies": {
"voc":"",
"commander":""
},
"devDependencies": {
"mocha":""
},
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-codepage.git"},
"scripts": {
"pretest": "git submodule init && git submodule update",
"test": "make test",
"build": "make js"
},
"config": {
"blanket": {
"pattern": "[cptable.js,cputils.js,cpexcel.js]"
}
},
"bugs": { "url": "https://github.com/SheetJS/js-codepage/issues" },
"license": "Apache-2.0",
"engines": { "node": ">=0.8" }

View File

@ -161,10 +161,12 @@
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});
@ -372,7 +374,7 @@
}
if(tt.length % 2 == 1) tt.length--;
o64 = decode(1201, tt);
for(var l = 0; l < o64.length; ++l) out[k++] = o64[l];
for(l = 0; l < o64.length; ++l) out[k++] = o64[l];
}
break;
default: throw new Error("Unsupported magic: " + cp + " " + magic[cp]);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -161,10 +161,12 @@
var encache +AD0 function(cp) +AHs
if(typeof Buffer +ACEAPQA9 'undefined') +AHs
sbcs+AF8-cache.forEach(function(s) +AHs
if(+ACE-cpt+AFs-s+AF0) return+ADs
cpdcache+AFs-s+AF0 +AD0 sbcs+AF8-decode(s)+ADs
cpecache+AFs-s+AF0 +AD0 sbcs+AF8-encode(s)+ADs
+AH0)+ADs
dbcs+AF8-cache.forEach(function(s) +AHs
if(+ACE-cpt+AFs-s+AF0) return+ADs
cpdcache+AFs-s+AF0 +AD0 dbcs+AF8-decode(s)+ADs
cpecache+AFs-s+AF0 +AD0 dbcs+AF8-encode(s)+ADs
+AH0)+ADs
@ -372,7 +374,7 @@
+AH0
if(tt.length +ACU 2 +AD0APQ 1) tt.length--+ADs
o64 +AD0 decode(1201, tt)+ADs
for(var l +AD0 0+ADs l +ADw o64.length+ADs +-+-l) out+AFs-k+-+-+AF0 +AD0 o64+AFs-l+AF0AOw
for(l +AD0 0+ADs l +ADw o64.length+ADs +-+-l) out+AFs-k+-+-+AF0 +AD0 o64+AFs-l+AF0AOw
+AH0
break+ADs
default: throw new Error(+ACI-Unsupported magic: +ACI +- cp +- +ACI +ACI +- magic+AFs-cp+AF0)+ADs

View File

@ -161,10 +161,12 @@
var encache = function(cp) {
if(typeof Buffer !== 'undefined') {
sbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = sbcs_decode(s);
cpecache[s] = sbcs_encode(s);
});
dbcs_cache.forEach(function(s) {
if(!cpt[s]) return;
cpdcache[s] = dbcs_decode(s);
cpecache[s] = dbcs_encode(s);
});
@ -372,7 +374,7 @@
}
if(tt.length % 2 == 1) tt.length--;
o64 = decode(1201, tt);
for(var l = 0; l < o64.length; ++l) out[k++] = o64[l];
for(l = 0; l < o64.length; ++l) out[k++] = o64[l];
}
break;
default: throw new Error("Unsupported magic: " + cp + " " + magic[cp]);

View File

@ -1,6 +1,6 @@
{
"name": "codepage",
"version": "1.0.0",
"version": "1.1.0",
"author": "SheetJS",
"description": "pure-JS library to handle codepages",
"keywords": [ "codepage", "iconv", "convert", "strings" ],
@ -23,7 +23,7 @@
},
"config": {
"blanket": {
"pattern": "[cptable.js,cputils.js]"
"pattern": "[cptable.js,cputils.js,cpexcel.js]"
}
},
"bugs": { "url": "https://github.com/SheetJS/js-codepage/issues" },

View File

@ -37,7 +37,7 @@ describe('consistency', function() {
cptable = require('./');
U = cptable.utils;
var chk = function(cptable, cacheit) { return function(x) {
it('should consistently process CP ' + x, function() {
it('should consistently process CP ' + x + ' ' + cacheit, function() {
var cp = cptable[x], D = cp.dec, E = cp.enc;
if(cacheit) cptable.utils.cache.encache();
else cptable.utils.cache.decache();