Skip to content

Commit

Permalink
Merge pull request #12537 from keymanapp/fix/developer/xml-reader-par…
Browse files Browse the repository at this point in the history
…se-text-decode

fix(developer): use TextDecoder to convert Uint8Array to string
  • Loading branch information
mcdurdin authored Oct 12, 2024
2 parents 6da9fa7 + 7dc787b commit f5c27c0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class KPJFileReader {
let data: KPJFile;

data = new KeymanXMLReader('kpj')
.parse(file.toString());
.parse(new TextDecoder().decode(file));

data = this.boxArrays(data);
if(data.KeymanDeveloperProject?.Files?.File?.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class KVKSFileReader {

try {
source = new KeymanXMLReader('kvks')
.parse(file.toString()) as KVKSourceFile;
.parse(new TextDecoder().decode(file)) as KVKSourceFile;
} catch(e) {
if(file.byteLength > 4 && file.subarray(0,3).every((v,i) => v == KVK_HEADER_IDENTIFIER_BYTES[i])) {
throw new Error('File appears to be a binary .kvk file', {cause: e});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class LDMLKeyboardXMLSourceFileReader {

loadTestDataUnboxed(file: Uint8Array): any {
const source = new KeymanXMLReader('keyboardTest3')
.parse(file.toString()) as any;
.parse(new TextDecoder().decode(file)) as any;
return source;
}

Expand Down
2 changes: 1 addition & 1 deletion developer/src/kmc-package/src/compiler/kmp-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class KmpCompiler implements KeymanCompiler {

try {
a = new KeymanXMLReader('kps')
.parse(data.toString()) as KpsFile.KpsPackage;
.parse(data) as KpsFile.KpsPackage;
} catch(e) {
this.callbacks.reportMessage(PackageCompilerMessages.Error_InvalidPackageFile({e}));
}
Expand Down

0 comments on commit f5c27c0

Please sign in to comment.