| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2314378 commit 589287b
1 file 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); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments