Skip to content

Commit 5b09c8b

Browse files
Set default_external encoding as UTF8 imitating major platforms
1 parent 365d19f commit 5b09c8b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/npm-packages/ruby-wasm-wasi/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class RubyVM {
4141
* @param args The command line arguments to pass to Ruby. Must be
4242
* an array of strings starting with the Ruby program name.
4343
*/
44-
initialize(args: string[] = ["ruby.wasm", "--disable-gems", "-e_=0"]) {
44+
initialize(
45+
args: string[] = ["ruby.wasm", "--disable-gems", "-EUTF-8", "-e_=0"]
46+
) {
4547
const c_args = args.map((arg) => arg + "\0");
4648
this.guest.rubyInit();
4749
this.guest.rubySysinit(c_args);

packages/npm-packages/ruby-wasm-wasi/test/vm.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ eval:11:in \`<main>'`);
231231

232232
test("eval encoding", async () => {
233233
const vm = await initRubyVM();
234+
expect(vm.eval(`Encoding.default_external.name`).toString()).toBe("UTF-8");
234235
expect(vm.eval(`"hello".encoding.name`).toString()).toBe("UTF-8");
235236
expect(vm.eval(`__ENCODING__.name`).toString()).toBe("UTF-8");
236237
});

0 commit comments

Comments
 (0)