From 21fb9a0a09d5834e857a35ed1e436017f69e955e Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Wed, 2 Nov 2022 22:50:58 +1000 Subject: [PATCH] Fix XBM decoding --- src/pages/tools/OEM.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/tools/OEM.tsx b/src/pages/tools/OEM.tsx index 6a6d467d..f3b57a30 100644 --- a/src/pages/tools/OEM.tsx +++ b/src/pages/tools/OEM.tsx @@ -38,15 +38,15 @@ const OEM = (): JSX.Element => { : []; const readFile = (file: File) => { - return new Promise((resolve: (value: ArrayBuffer) => void, reject) => { + return new Promise((resolve: (value: string) => void, reject) => { const reader = new FileReader(); reader.onload = (res) => { - resolve(res.target.result as ArrayBuffer); + resolve(res.target.result as string); }; reader.onerror = (err) => reject(err); - reader.readAsArrayBuffer(file); + reader.readAsText(file); }); }; @@ -100,7 +100,11 @@ const OEM = (): JSX.Element => { name="file" onChange={(e) => { readFile(e.target.files[0]).then((data) => { - setOemIconBits(new Uint8Array(data)); + setOemIconBits( + new Uint8Array( + data.split(',').map((s) => parseInt(s.trim(), 16)), + ), + ); }); }} />