Skip to content

Commit 402a7e7

Browse files
author
Akos Kitta
committed
fix: encoding when reading a cloud sketch
Closes #449 Closes #634 Signed-off-by: Akos Kitta <[email protected]>
1 parent 01ee045 commit 402a7e7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arduino-ide-extension/src/browser/create/create-fs-provider.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ export class CreateFsProvider
154154

155155
async readFile(uri: URI): Promise<Uint8Array> {
156156
const content = await this.getCreateApi.readFile(uri.path.toString());
157-
return new TextEncoder().encode(content);
157+
// Text encoder can crash in electron browser: https://github.com/arduino/arduino-ide/issues/634#issuecomment-1440039171
158+
// Credit for the workaround: https://stackoverflow.com/a/45722000/5529090
159+
return Uint8Array.from(content, (char) => char.charCodeAt(0));
158160
}
159161

160162
async writeFile(

0 commit comments

Comments
 (0)