Skip to content

Commit 7745bcf

Browse files
committed
version bump 1.6.0: IE6+ compatibility
- removed string indexing from table generation - browser tests - expanded flow checks
1 parent ff120df commit 7745bcf

File tree

173 files changed

+2034
-1585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+2034
-1585
lines changed

.flowconfig

+4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717

1818
[include]
1919
cputils.flow.js
20+
.*/bin/.*.njs
2021

2122
[libs]
2223
misc/flow.js
24+
misc/flowdeps.js
2325

2426
[options]
27+
module.file_ext=.js
28+
module.file_ext=.njs

Makefile

+14-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ SHELL=/bin/bash
22
VOC=voc
33
TARGET=cptable.js
44
AUXTARGETS=cputils.js cpexcel.js sbcs.js
5+
DISTFULL=cpexcel sbcs cptable
6+
CMDS=bin/codepage.njs
7+
8+
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
59

610
## Main Targets
711

@@ -19,16 +23,17 @@ js: make.sh codepage.md ## Build all output targets
1923
bash make.sh
2024
make cputils.js
2125

22-
cputils.js: %.js : %.flow.js
26+
cputils.js: cputils.flow.js
2327
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/[ \t]*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
2428

2529
.PHONY: clean
2630
clean: ## Remove targets and build artifaats
2731
rm -f make.sh .vocrc pages.csv bits/*.js
2832

29-
.PHONY: dist ## Copy files for distribution
30-
dist: $(TARGET) $(AUXTARGETS)
33+
.PHONY: dist
34+
dist: $(TARGET) $(AUXTARGETS) ## Copy files for distribution
3135
cp $(TARGET) $(AUXTARGETS) LICENSE dist/
36+
for i in $(DISTFULL); do cat $$i.js cputils.js > dist/$$i.full.js; done
3237

3338
## Testing
3439

@@ -42,17 +47,22 @@ ctest: ## Build browser test (into ctest/ subdirectory)
4247

4348
.PHONY: ctestserv
4449
ctestserv: ## Start a test server on port 8000
45-
@python -mSimpleHTTPServer
50+
@cd ctest && python -mSimpleHTTPServer
4651

4752
.PHONY: baseline
4853
baseline: ## Build test baselines
4954
@bash ./misc/make_baseline.sh
5055

56+
.PHONY: clean-baseline
57+
clean-baseline: ## Remove test baselines
58+
@bash ./misc/make_baseline.sh clean
59+
5160
## Code Checking
5261

5362
.PHONY: lint
5463
lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
5564
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
65+
@jshint --show-non-errors $(CMDS)
5666
@jshint --show-non-errors package.json
5767
@jshint --show-non-errors --extract=always $(HTMLLINT)
5868
@jscs $(TARGET) $(AUXTARGETS)
@@ -77,7 +87,6 @@ prof:
7787
node --prof prof.js
7888

7989

80-
8190
.PHONY: help
8291
help:
8392
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh

README.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# Codepages for JS
1+
# js-codepage
22

33
[Codepages](https://en.wikipedia.org/wiki/Codepage) are character encodings. In
44
many contexts, single- or double-byte character sets are used in lieu of Unicode
55
encodings. The codepages map between characters and numbers.
66

7-
[unicode.org](http://www.unicode.org/Public/MAPPINGS/) hosts lists of mappings.
8-
The build script automatically downloads and parses the mappings in order to
9-
generate the full script. The `pages.csv` description in `codepage.md` controls
10-
which codepages are used.
11-
127
## Setup
138

149
In node:
@@ -317,15 +312,33 @@ unicode.org does not prescribe a value, MakeEncoding.cs value is used.
317312
of Windows. In older versions of Windows (e.g. Windows 98) these files followed
318313
the name pattern `CP_#.NLS`, but newer versions use the name pattern `C_#.NLS`.
319314

315+
## Testing
316+
317+
`make test` will run the nodejs-based test.
318+
319+
To run the in-browser tests, run a local server and go to the `ctest` directory.
320+
`make ctestserv` will start a python `SimpleHTTPServer` server on port 8000.
321+
322+
To update the browser artifacts, run `make ctest`.
323+
320324
## Sources
321325

322326
- [Unicode Consortium Public Mappings](http://www.unicode.org/Public/MAPPINGS/)
323327
- [Windows Code Page Enumeration](http://msdn.microsoft.com/en-us/library/cc195051.aspx)
324328
- [Windows Code Page Identifiers](http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756.aspx)
325329
- [IBM Coded Character Sets](https://www-01.ibm.com/software/globalization/ccsid/ccsid_registered.html)
326330

331+
## License
332+
333+
Please consult the attached LICENSE file for details. All rights not explicitly
334+
granted by the Apache 2.0 license are reserved by the Original Author.
335+
327336
## Badges
328337

338+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/codepage.svg)](https://saucelabs.com/u/codepage)
339+
329340
[![Build Status](https://travis-ci.org/SheetJS/js-codepage.svg?branch=master)](https://travis-ci.org/SheetJS/js-codepage)
330-
[![Coverage Status](https://coveralls.io/repos/SheetJS/js-codepage/badge.png)](https://coveralls.io/r/SheetJS/js-codepage)
341+
342+
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-codepage/master.svg)](https://coveralls.io/r/SheetJS/js-codepage?branch=master)
343+
331344
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-codepage?pixel)](https://github.com/SheetJS/js-codepage)

bin/codepage.njs

+13-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* vim: set ts=2 ft=javascript: */
44
var codepage = require('../');
55
require('exit-on-epipe');
6-
var fs = require('fs'), program = require('commander');
6+
var fs = require('fs'), program/*:any*/ = (require('commander')/*:any*/);
77
program
88
.version(codepage.version)
99
.usage('[options] <file>')
@@ -23,7 +23,10 @@ program.on('--help', function() {
2323
program.parse(process.argv);
2424

2525
if(program.list) {
26-
Object.keys(codepage).forEach(function(x) { if(+x == x) console.log(x); });
26+
var l/*:Array<number>*/ = [];
27+
Object.keys(codepage).forEach(function(x) { if(parseInt(x) == +x) l.push(+x); });
28+
Object.keys(codepage.utils.magic).forEach(function(x) { if(parseInt(x) == +x && +x != 16969) l.push(+x); });
29+
l.sort(function(a,b) { return a-b; }).forEach(function(x) { console.log(x); });
2730
process.exit();
2831
}
2932

@@ -45,15 +48,14 @@ else process_text(fs.readFileSync(f));
4548
function process_text(text) {
4649
var dec = codepage.utils.decode(fr, text);
4750

48-
var bom = {
49-
1200: new Buffer([0xFF, 0xFE]),
50-
1201: new Buffer([0xFE, 0xFF]),
51-
12000: new Buffer([0xFF, 0xFE, 0x00, 0x00]),
52-
12001: new Buffer([0x00, 0x00, 0xFE, 0xFF]),
53-
16969: new Buffer([0x69, 0x69]),
54-
65000: new Buffer([0x2B, 0x2F, 0x76, 0x2B]),
55-
65001: new Buffer([0xEF, 0xBB, 0xBF])
56-
}
51+
var bom/*:Array<Buffer>*/ = [];
52+
bom[1200] = new Buffer([0xFF, 0xFE]);
53+
bom[1201] = new Buffer([0xFE, 0xFF]);
54+
bom[12000] = new Buffer([0xFF, 0xFE, 0x00, 0x00]);
55+
bom[12001] = new Buffer([0x00, 0x00, 0xFE, 0xFF]);
56+
bom[16969] = new Buffer([0x69, 0x69]);
57+
bom[65000] = new Buffer([0x2B, 0x2F, 0x76, 0x2B]);
58+
bom[65001] = new Buffer([0xEF, 0xBB, 0xBF]);
5759

5860
var mybom = (program.bom && bom[fr] ? bom[fr] : "");
5961
var out = to === 65001 ? dec.toString('utf8') : codepage.utils.encode(to, dec);

bits/10000.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10004.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10005.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10006.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10007.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10010.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10017.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10021.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bits/10029.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)