Skip to content

Commit cae4138

Browse files
committed
fix
1 parent 7375672 commit cae4138

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

runtime/mlBytes.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,15 @@ var jsoo_text_decoder = new TextDecoder();
328328

329329
//Provides: caml_bytes_of_utf16_jsstring
330330
//Requires: MlBytes, jsoo_text_encoder
331+
//Requires: jsoo_is_ascii
331332
function caml_bytes_of_utf16_jsstring(s) {
332-
var a = jsoo_text_encoder.encode(s);
333-
return new MlBytes(4, a, a.length);
333+
if(jsoo_is_ascii(s)){
334+
return new MlBytes(9, s, s.length)
335+
}
336+
else {
337+
var a = jsoo_text_encoder.encode(s);
338+
return new MlBytes(4, a, a.length);
339+
}
334340
}
335341

336342
//Provides: MlBytes
@@ -697,8 +703,10 @@ function caml_jsstring_of_string(s) {
697703
//Provides: caml_string_of_jsstring const
698704
//Requires: caml_string_of_array
699705
//Requires: jsoo_text_encoder
706+
//Requires: jsoo_is_ascii, caml_string_of_jsbytes
700707
//If: js-string
701708
function caml_string_of_jsstring(s) {
709+
if(jsoo_is_ascii(s)) return caml_string_of_jsbytes(s);
702710
var a = jsoo_text_encoder.encode(s);
703711
return caml_string_of_array(a);
704712
}

0 commit comments

Comments
 (0)