1 /** 2 * Copyright (c) 2021-2023 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 #include "intrinsics.h" 17 18 namespace panda::ets::intrinsics { 19 20 const char LOWER_TO_UPPER_OFFSET = 'a' - 'A'; 21 StdCoreCharIsUpperCase(EtsChar value)22extern "C" EtsBoolean StdCoreCharIsUpperCase(EtsChar value) 23 { 24 return ToEtsBoolean(value >= 'A' && value <= 'Z'); 25 } StdCoreCharToUpperCase(EtsChar value)26extern "C" EtsChar StdCoreCharToUpperCase(EtsChar value) 27 { 28 return (value >= 'a' && value <= 'z') ? value - LOWER_TO_UPPER_OFFSET : value; 29 } StdCoreCharIsLowerCase(EtsChar value)30extern "C" EtsBoolean StdCoreCharIsLowerCase(EtsChar value) 31 { 32 return ToEtsBoolean(value >= 'a' && value <= 'z'); 33 } StdCoreCharToLowerCase(EtsChar value)34extern "C" EtsChar StdCoreCharToLowerCase(EtsChar value) 35 { 36 return (value >= 'A' && value <= 'Z') ? value + LOWER_TO_UPPER_OFFSET : value; 37 } 38 39 } // namespace panda::ets::intrinsics 40