1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_PLATFORM_JSON_HELPER_INTERNAL_COMMON_H 17 #define ECMASCRIPT_PLATFORM_JSON_HELPER_INTERNAL_COMMON_H 18 namespace panda::ecmascript::base { 19 class JsonHelperInternal { 20 friend class JsonPlatformHelper; 21 private: ReadJsonStringRangeForUtf8(bool & isFastString,const uint8_t * current,const uint8_t * range,const uint8_t * & end)22 static bool ReadJsonStringRangeForUtf8(bool &isFastString, const uint8_t *current, 23 const uint8_t *range, const uint8_t *&end) 24 { 25 for (const uint8_t *cur = current; cur != range; ++cur) { 26 uint8_t c = *cur; 27 if (c == '"') { 28 end = cur; 29 return true; 30 } 31 if (c == '\\') { 32 isFastString = false; 33 return true; 34 } 35 if (c < ' ') { 36 return false; 37 } 38 } 39 return false; 40 } 41 }; 42 } 43 #endif //ECMASCRIPT_PLATFORM_JSON_HELPER_INTERNAL_COMMON_H 44