Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Dec 4, 2024
1 parent 5ef931e commit 9724287
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions runtime/js/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,14 @@ 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 @@ -648,8 +653,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 9724287

Please sign in to comment.