Support UTF-8 decoding for non-buffer input

Fixes #2081
This commit is contained in:
Richard Gibson 2021-10-05 20:23:44 -04:00 committed by GitHub
parent 71160160d1
commit 3af23c31dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -940,6 +940,7 @@ var PRN = (function() {
default: throw new Error("Unrecognized type " + opts.type);
}
if(bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str.slice(3));
else if(opts.type != 'string' && opts.codepage == 65001) str = utf8read(str);
else if((opts.type == 'binary') && typeof cptable !== 'undefined' && opts.codepage) str = cptable.utils.decode(opts.codepage, cptable.utils.encode(28591,str));
if(str.slice(0,19) == "socialcalc:version:") return ETH.to_sheet(opts.type == 'string' ? str : utf8read(str), opts);
return prn_to_sheet_str(str, opts);