1 /* 2 * Copyright (c) 2021 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 #ifndef OHOS_GLOBAL_I18N_UTILS_H 16 #define OHOS_GLOBAL_I18N_UTILS_H 17 18 #include <regex> 19 #include <string> 20 #include <vector> 21 #include <unordered_set> 22 #include <unicode/locid.h> 23 #include "set" 24 #include "i18n_types.h" 25 26 namespace OHOS { 27 namespace Global { 28 namespace I18n { 29 static std::set<std::string> availableIDs; 30 31 void Split(const std::string &src, const std::string &sep, std::vector<std::string> &dest); 32 void Merge(const std::vector<std::string>& src, const std::string& sep, std::string& dest); 33 std::string ReadSystemParameter(const char *paramKey, const int paramLength); 34 int32_t ConvertString2Int(const std::string &numberStr, int32_t& status); 35 bool IsValidLocaleTag(icu::Locale &locale); 36 void GetAllValidLocalesTag(std::unordered_set<std::string>& allValidLocalesLanguageTag); 37 bool CheckTzDataFilePath(const std::string &filePath); 38 std::string StrReplaceAll(const std::string& str, 39 const std::string& target, const std::string& replace); 40 std::string GetISO3Language(const std::string& language); 41 std::string GetISO3Country(const std::string& country); 42 std::string trim(std::string &s); 43 bool FileExist(const std::string& path); 44 bool FileCopy(const std::string& srcPath, const std::string& dstPath); 45 bool IsLegalPath(const std::string& path); 46 void Split(const std::string &src, const std::string &sep, std::vector<std::string> &dest); 47 bool IsDirExist(const char *path); 48 bool GetPseudoLocalizationEnforce(); 49 std::string PseudoLocalizationProcessor(const std::string &input); 50 std::string PseudoLocalizationProcessor(const std::string &input, bool ifEnforce); 51 bool CheckSystemPermission(); 52 size_t ConvertBytesToSizeT(const char *byteArray); 53 std::set<std::string> GetTimeZoneAvailableIDs(I18nErrorCode &errorCode); 54 bool RegexSearchNoExcept(const std::string& str, std::smatch& match, const std::regex& regex); 55 } // namespace I18n 56 } // namespace Global 57 } // namespace OHOS 58 #endif