Skip to content

Commit 0ada6f6

Browse files
committed
version bump 1.12.0: infrastructure
1 parent b070fe0 commit 0ada6f6

Some content is hidden

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

63 files changed

+669
-255
lines changed

.eslintrc

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"ecmaVersion": 3,
66
},
77
"plugins": [ "html", "json" ],
8-
"!extends": "eslint:recommended",
8+
"extends": "eslint:recommended",
99
"rules": {
10-
"no-console": 0,
11-
"no-bitwise": 0,
12-
"curly": 0,
1310
"comma-style": [ 2, "last" ],
11+
"comma-dangle": [ 2, "never" ],
12+
"curly": 0,
13+
"no-bitwise": 0,
14+
"no-console": 0,
1415
"no-trailing-spaces": 2,
15-
"semi": [ 2, "always" ],
16-
"comma-dangle": [ 2, "never" ]
16+
"semi": [ 2, "always" ]
1717
}
1818
}

.flowconfig

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.*/prof.js
1313
.*/cputils.js
1414
.*/cptable.js
15+
.*/cpexcel.js
1516
.*/sbcs.js
1617
.*/dbcs.js
1718

.spelling

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# codepage.js (C) 2013-present SheetJS -- http://sheetjs.com
2+
SheetJS
3+
js-codepage
4+
codepage
5+
encoding
6+
7+
# Encoding-related terms
8+
Big5
9+
GB2312
10+
GB2312-80
11+
Johab
12+
Kamenický
13+
KOI8
14+
Mazovia
15+
Shift-JIS
16+
T.61
17+
UTF-16
18+
UTF-32
19+
UTF-7
20+
UTF-8
21+
Wansung
22+
halfwidth
23+
24+
# Third-party
25+
FoxPro
26+
nodejs
27+
unicode.org
28+
29+
# Other terms
30+
codepages
31+
codepoint
32+
codepoints
33+
encodings
34+
endian
35+
repo
36+
runtime

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ clean-baseline: ## Remove test baselines
6262

6363
## Code Checking
6464

65+
.PHONY: fullint
66+
fullint: lint old-lint tslint flow mdlint ## Run all checks
67+
6568
.PHONY: lint
6669
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
6770
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
@@ -76,6 +79,11 @@ old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
7679
@jscs $(TARGET) $(AUXTARGETS)
7780
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
7881

82+
.PHONY: tslint
83+
tslint: $(TARGET) ## Run typescript checks
84+
#@npm install dtslint typescript
85+
#@npm run-script dtslint
86+
dtslint types
7987

8088
.PHONY: flow
8189
flow: lint ## Run flow checker
@@ -91,6 +99,12 @@ misc/coverage.html: $(TARGET) test.js
9199
coveralls: ## Coverage Test + Send to coveralls.io
92100
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
93101

102+
MDLINT=README.md codepage.md
103+
.PHONY: mdlint
104+
mdlint: $(MDLINT) ## Check markdown documents
105+
alex $^
106+
mdspell -a -n -x -r --en-us $^
107+
94108
.PHONY: prof
95109
prof:
96110
cat misc/prof.js test.js > prof.js

README.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ the object, edit the `JSVAR` shell variable in `make.sh` and run the script.
4848
The utilities functions are contained in `cputils.js`, which assumes that the
4949
appropriate codepage scripts were loaded.
5050

51-
The script will manipulate `module.exports` if available (e.g. in a CommonJS
52-
`require` context). This is not always desirable. To prevent the behavior,
53-
define `DO_NOT_EXPORT_CODEPAGE`.
51+
The script will manipulate `module.exports` if available . This is not always
52+
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CODEPAGE`.
5453

5554
## Usage
5655

57-
Most codepages are indexed by number. To get the unicode character for a given
56+
Most codepages are indexed by number. To get the Unicode character for a given
5857
codepoint, use the `dec` property:
5958

6059
```js
@@ -79,8 +78,8 @@ var sbuf = cptable.utils.encode(65001, sushi);
7978
`cptable.utils.encode(CP, data, ofmt)` accepts a String or Array of characters
8079
and returns a representation controlled by `ofmt`:
8180

82-
- Default output is a Buffer (or Array) of bytes (integers between 0 and 255).
83-
- If `ofmt == 'str'`, return a String where `o.charCodeAt(i)` is the `i`-th byte
81+
- Default output is a Buffer (or Array) of bytes (integers between 0 and 255)
82+
- If `ofmt == 'str'`, return a binary String (byte `i` is `o.charCodeAt(i)`)
8483
- If `ofmt == 'arr'`, return an Array of bytes
8584

8685
`cptable.utils.decode(CP, data)` accepts a byte String or Array of numbers or
@@ -112,7 +111,7 @@ $ bash make.sh path_to_manifest output_file_name JSVAR
112111
where
113112

114113
- `JSVAR` is the name of the exported variable (generally `cptable`)
115-
- `output_file_name` is the output file (e.g. `cpexcel.js`, `cptable.js`)
114+
- `output_file_name` is the output file (`cpexcel.js`, `cptable.js`, ...)
116115
- `path_to_manifest` is the path to the manifest file.
117116

118117
The manifest file is expected to be a CSV with 3 columns:
@@ -138,10 +137,10 @@ the JS source is `codepage.md`, so building is as simple as `voc codepage.md`.
138137

139138
## Generated Codepages
140139

141-
The complete list of hardcoded codepages can be found in the file `pages.csv`.
140+
The complete list of codepages can be found in the file `pages.csv`.
142141

143-
Some codepages are easier to implement algorithmically. Since these are
144-
hardcoded in `utils`, there is no corresponding entry (they are "magic").
142+
Some codepages are easier to implement algorithmically. Since those character
143+
tables are not generated, there is no corresponding entry (they are "magic").
145144

146145
| CP# | Source | Description |
147146
|--------:|:-----------:|:-----------------------------------------------------|
@@ -222,7 +221,7 @@ hardcoded in `utils`, there is no corresponding entry (they are "magic").
222221
| `12001` | magic | Unicode UTF-32, big endian byte order |
223222
| `20000` | Windows 7 | CNS Taiwan (Chinese Traditional) |
224223
| `20001` | Windows 7 | TCA Taiwan |
225-
| `20002` | Windows 7 | Eten Taiwan (Chinese Traditional) |
224+
| `20002` | Windows 7 | ETEN Taiwan (Chinese Traditional) |
226225
| `20003` | Windows 7 | IBM5550 Taiwan |
227226
| `20004` | Windows 7 | TeleText Taiwan |
228227
| `20005` | Windows 7 | Wang Taiwan |
@@ -299,21 +298,21 @@ hardcoded in `utils`, there is no corresponding entry (they are "magic").
299298
| `65001` | magic | Unicode (UTF-8) |
300299

301300
`unicode.org` refers to the Unicode Consortium Public Mappings, a database of
302-
various mappings between unicode characters and respective character sets. The
301+
various mappings between Unicode characters and respective character sets. The
303302
tables are processed by a few scripts in the build process.
304303

305304
`IBM` refers to the IBM coded character set database. Even though IBM uses a
306305
different numbering scheme from Windows, the IBM numbers are used when there is
307-
no conflict. The tables are manually generated from the symbol PDFs.
306+
no conflict. The tables are manually generated from the symbol manifests.
308307

309308
`Windows 7` refers to direct inspection of Windows 7 machines using .NET class
310309
`System.Text.Encoding`. The enclosed `MakeEncoding.cs` C# program brute-forces
311-
code pages. MakeEncoding.cs deviates from unicode.org in some cases. When they
310+
code pages. `MakeEncoding.cs` deviates from unicode.org in some cases. When they
312311
map a given code to different characters, unicode.org value is used. When
313-
unicode.org does not prescribe a value, MakeEncoding.cs value is used.
312+
unicode.org does not prescribe a value, `MakeEncoding.cs` value is used.
314313

315314
`NLS` refers to the National Language Support files supplied in various versions
316-
of Windows. In older versions of Windows (e.g. Windows 98) these files followed
315+
of Windows. In older versions of Windows (like Windows 98) these files followed
317316
the name pattern `CP_#.NLS`, but newer versions use the name pattern `C_#.NLS`.
318317

319318
## Testing

bin/codepage.njs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22
/* js-codepage (C) 2014-present SheetJS -- http://sheetjs.com */
33
/* vim: set ts=2 ft=javascript: */
4+
/* eslint-env node */
45
var codepage = require('../');
56
require('exit-on-epipe');
67
var fs = require('fs'), program/*:any*/ = (require('commander')/*:any*/);
@@ -24,8 +25,8 @@ program.parse(process.argv);
2425

2526
if(program.list) {
2627
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); });
28+
Object.keys(codepage).forEach(function(x) { if(parseInt(x, 10) == +x) l.push(+x); });
29+
Object.keys(codepage.utils.magic).forEach(function(x) { if(parseInt(x, 10) == +x && +x != 16969) l.push(+x); });
2930
l.sort(function(a,b) { return a-b; }).forEach(function(x) { console.log(x); });
3031
process.exit();
3132
}
@@ -43,19 +44,20 @@ if(f !== "-" && !fs.existsSync(f)) {
4344
}
4445

4546
function concat(func) {
47+
// $FlowIgnore
4648
var writable = require('stream').Writable();
4749
var buf = [];
48-
writable._write = function(chunk, e, cb) { console.error(chunk.length); buf.push(chunk); cb(); };
49-
writable._writev = function(chunks, cb) { console.error(chunks.length, chunks.map(x => x.length)); chunks.forEach(function(c) { buf.push(c); cb(); }); };
50-
writable.on('finish', function() { console.error(buf.length, "end"); func(Buffer.concat(buf)); });
50+
writable._write = function(chunk, e, cb) { buf.push(chunk); cb(); };
51+
writable._writev = function(chunks, cb) { chunks.forEach(function(c) { buf.push(c.chunk); cb(); }); };
52+
writable.on('finish', function() { func(Buffer.concat(buf)); });
5153
return writable;
5254
}
5355

5456
if(f === "-") process.stdin.pipe(concat(process_text));
5557
else process_text(fs.readFileSync(f));
5658

5759
function process_text(text/*:Buffer*/) {
58-
var dec/*:Buffer*/ = codepage.utils.decode(fr, text);
60+
var dec/*:Buffer*/ = (codepage.utils.decode(fr, text)/*:any*/);
5961

6062
var bom/*:Array<Buffer>*/ = [];
6163
bom[1200] = new Buffer([0xFF, 0xFE]);

0 commit comments

Comments
 (0)