Skip to content

Commit 4a31cb9

Browse files
committed
warn on codepage override in mini build [ci skip]
1 parent a373597 commit 4a31cb9

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

bits/40_harb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function dbf_to_aoa(buf, opts)/*:AOA*/ {
119119
var ww = l7 ? 32 : 11;
120120
while(d.l < hend && d[d.l] != 0x0d) {
121121
field = ({}/*:any*/);
122-
field.name = $cptable.utils.decode(current_cp, d.slice(d.l, d.l+ww)).replace(/[\u0000\r\n].*$/g,"");
122+
field.name = (typeof $cptable !== "undefined" ? $cptable.utils.decode(current_cp, d.slice(d.l, d.l+ww)) : a2s(d.slice(d.l, d.l + ww))).replace(/[\u0000\r\n].*$/g,"");
123123
d.l += ww;
124124
field.type = String.fromCharCode(d.read_shift(1));
125125
if(ft != 0x02 && !l7) field.offset = d.read_shift(4);
@@ -173,7 +173,7 @@ function dbf_to_aoa(buf, opts)/*:AOA*/ {
173173
for(C = 0; C != fields.length; ++C) {
174174
var dd = d.slice(d.l, d.l+fields[C].len); d.l+=fields[C].len;
175175
prep_blob(dd, 0);
176-
var s = $cptable.utils.decode(current_cp, dd);
176+
var s = typeof $cptable !== "undefined" ? $cptable.utils.decode(current_cp, dd) : a2s(dd);
177177
switch(fields[C].type) {
178178
case 'C':
179179
// NOTE: it is conventional to write ' / / ' for empty dates

bits/67_wsxml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ function write_ws_xml_sheetviews(ws, opts, idx, wb)/*:string*/ {
258258

259259
function write_ws_xml_cell(cell/*:Cell*/, ref, ws, opts/*::, idx, wb*/)/*:string*/ {
260260
if(cell.c) ws['!comments'].push([ref, cell.c]);
261-
if(cell.v === undefined && typeof cell.f !== "string" || cell.t === 'z' && !cell.f) return "";
261+
if((cell.v === undefined || cell.t === "z" && !(opts||{}).sheetStubs) && typeof cell.f !== "string" && typeof cell.z == "undefined") return "";
262262
var vv = "";
263263
var oldt = cell.t, oldv = cell.v;
264264
if(cell.t !== "z") switch(cell.t) {

bits/71_wbcommon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function safe1904(wb/*:Workbook*/)/*:string*/ {
113113
return parsexmlbool(wb.Workbook.WBProps.date1904) ? "true" : "false";
114114
}
115115

116-
var badchars = /*#__PURE__*/"][*?\/\\".split("");
116+
var badchars = /*#__PURE__*/":][*?\/\\".split("");
117117
function check_ws_name(n/*:string*/, safe/*:?boolean*/)/*:boolean*/ {
118118
if(n.length > 31) { if(safe) return false; throw new Error("Sheet names cannot exceed 31 chars"); }
119119
var _good = true;

bits/87_read.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function read_plaintext_raw(data/*:RawData*/, o/*:ParseOpts*/)/*:Workbook*/ {
5050
function read_utf16(data/*:RawData*/, o/*:ParseOpts*/)/*:Workbook*/ {
5151
var d = data;
5252
if(o.type == 'base64') d = Base64_decode(d);
53-
d = $cptable.utils.decode(1200, d.slice(2), 'str');
53+
d = typeof $cptable !== "undefined" ? $cptable.utils.decode(1200, d.slice(2), 'str') : utf16leread(d.slice(2));
5454
o.type = "binary";
5555
return read_plaintext(d, o);
5656
}
@@ -67,6 +67,7 @@ function read_prn(data, d, o, str) {
6767
function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
6868
reset_cp();
6969
var o = opts||{};
70+
if(o.codepage && typeof $cptable === "undefined") console.error("Codepage tables are not loaded. Non-ASCII characters may not give expected results");
7071
if(typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) return readSync(new Uint8Array(data), (o = dup(o), o.type = "array", o));
7172
if(typeof Uint8Array !== 'undefined' && data instanceof Uint8Array && !o.type) o.type = typeof Deno !== "undefined" ? "buffer" : "array";
7273
var d = data, n = [0,0,0,0], str = false;

0 commit comments

Comments
 (0)