Verified Commit 4f97cc46 authored by Camil Staps's avatar Camil Staps 🙂

JavaScript get_clean_string: add support to change encoding

parent 4c901dc8
Pipeline #27887 passed with stages
in 17 minutes and 4 seconds
......@@ -341,7 +341,7 @@ class ABCInterpreter {
get_clean_string (hp_ptr, string_may_be_discarded=false) {
get_clean_string (hp_ptr, string_may_be_discarded=false, encoding='x-user-defined') {
const size=this.memory_array[hp_ptr/4+2];
if (string_may_be_discarded) {
......@@ -366,8 +366,10 @@ class ABCInterpreter {
const string_buffer=new Uint8Array(this.memory.buffer, hp_ptr+16, size);
if (typeof TextDecoder!='undefined') {
return new TextDecoder('x-user-defined').decode(string_buffer);
return new TextDecoder(encoding).decode(string_buffer);
} else {
if (encoding!='x-user-defined')
console.warn('get_clean_string: this browser does not have TextDecoder; string could not be decoded using '+encoding);
var string='';
for (var i=0; i<size; i++)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment