File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -842,11 +842,27 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
842
842
return args.GetReturnValue ().Set (-1 );
843
843
}
844
844
845
- result = SearchString (reinterpret_cast <const uint16_t *>(haystack),
846
- haystack_length / 2 ,
847
- reinterpret_cast <const uint16_t *>(*needle_value),
848
- needle_value.length (),
849
- offset / 2 );
845
+ if (IsBigEndian ()) {
846
+ StringBytes::InlineDecoder decoder;
847
+ decoder.Decode (Environment::GetCurrent (args), needle, args[3 ], UCS2);
848
+ const uint16_t * decoded_string =
849
+ reinterpret_cast <const uint16_t *>(decoder.out ());
850
+
851
+ if (decoded_string == nullptr )
852
+ return args.GetReturnValue ().Set (-1 );
853
+
854
+ result = SearchString (reinterpret_cast <const uint16_t *>(haystack),
855
+ haystack_length / 2 ,
856
+ decoded_string,
857
+ decoder.size () / 2 ,
858
+ offset / 2 );
859
+ } else {
860
+ result = SearchString (reinterpret_cast <const uint16_t *>(haystack),
861
+ haystack_length / 2 ,
862
+ reinterpret_cast <const uint16_t *>(*needle_value),
863
+ needle_value.length (),
864
+ offset / 2 );
865
+ }
850
866
result *= 2 ;
851
867
} else if (enc == UTF8) {
852
868
String::Utf8Value needle_value (needle);
You can’t perform that action at this time.
0 commit comments