File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -283,9 +283,14 @@ var jsoo_text_decoder = new TextDecoder();
283283
284284//Provides: caml_bytes_of_utf16_jsstring
285285//Requires: MlBytes, jsoo_text_encoder
286+ //Requires: jsoo_is_ascii
286287function caml_bytes_of_utf16_jsstring ( s ) {
287- var a = jsoo_text_encoder . encode ( s ) ;
288- return new MlBytes ( 4 , a , a . length ) ;
288+ if ( jsoo_is_ascii ( s ) ) {
289+ return new MlBytes ( 9 , s , s . length ) ;
290+ } else {
291+ var a = jsoo_text_encoder . encode ( s ) ;
292+ return new MlBytes ( 4 , a , a . length ) ;
293+ }
289294}
290295
291296//Provides: MlBytes
@@ -670,8 +675,10 @@ function caml_jsstring_of_string(s) {
670675//Provides: caml_string_of_jsstring const
671676//Requires: caml_string_of_array
672677//Requires: jsoo_text_encoder
678+ //Requires: jsoo_is_ascii, caml_string_of_jsbytes
673679//If: js-string
674680function caml_string_of_jsstring ( s ) {
681+ if ( jsoo_is_ascii ( s ) ) return caml_string_of_jsbytes ( s ) ;
675682 var a = jsoo_text_encoder . encode ( s ) ;
676683 return caml_string_of_array ( a ) ;
677684}
You can’t perform that action at this time.
0 commit comments