[this is a question about JavaScript not in web/HTML context]
Is there a way to force any particular (i.e. UTF-8) encoding for source JavaScript files in gjs? I'm facing a problem where the first file run directly from command line ($ gjs test.js
) is read as UTF-8, but any imported module is in some single-byte encoding, which is pretty much useless for non-English users.
Simple test case I have (the strings include fancy non-ASCII quotes). File test.js
:
print ("test “1”");
imports.searchPath.push ('.');
imports.test2.foo ();
File test2.js
:
function foo () {
print ("test “2”");
}
When the testcase is run as $ gjs test.js
, it gives the following output:
test “1”
test â2â
As you use, directly invoked file test.js
does produce correct output, while strings in the imported module get garbled. Is there any way to make gjs parse imported module as UTF-8?