Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Oct 24, 2024
1 parent 7375672 commit cae4138
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runtime/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,15 @@ var jsoo_text_decoder = new TextDecoder();

//Provides: caml_bytes_of_utf16_jsstring
//Requires: MlBytes, jsoo_text_encoder
//Requires: jsoo_is_ascii
function caml_bytes_of_utf16_jsstring(s) {
var a = jsoo_text_encoder.encode(s);
return new MlBytes(4, a, a.length);
if(jsoo_is_ascii(s)){
return new MlBytes(9, s, s.length)
}
else {
var a = jsoo_text_encoder.encode(s);
return new MlBytes(4, a, a.length);
}
}

//Provides: MlBytes
Expand Down Expand Up @@ -697,8 +703,10 @@ function caml_jsstring_of_string(s) {
//Provides: caml_string_of_jsstring const
//Requires: caml_string_of_array
//Requires: jsoo_text_encoder
//Requires: jsoo_is_ascii, caml_string_of_jsbytes
//If: js-string
function caml_string_of_jsstring(s) {
if(jsoo_is_ascii(s)) return caml_string_of_jsbytes(s);
var a = jsoo_text_encoder.encode(s);
return caml_string_of_array(a);
}
Expand Down

0 comments on commit cae4138

Please sign in to comment.