1 /* 2 * Copyright (c) 2021-2022 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 CHARACTER_TRANSLITERATE_H 17 #define CHARACTER_TRANSLITERATE_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace Contacts { 24 struct ChineseTable { 25 // The first letter of Pinyin 26 std::string initials; 27 // Pinyin 28 std::string nameFullFight_; 29 std::string chineseCharacters_; 30 }; 31 32 struct Container { 33 // The container of first letter 34 std::vector<std::vector<std::wstring>> initialsContainer_; 35 // Pinyin container 36 std::vector<std::vector<std::wstring>> nameFullFightContainer_; 37 }; 38 39 class CharacterTransliterate { 40 public: 41 CharacterTransliterate(); 42 ~CharacterTransliterate(); 43 static ChineseTable chineseTable_[]; 44 bool IsChineseCharacter(wchar_t chineseCharacter); 45 Container GetContainer(std::wstring wChinese); 46 std::wstring Join(std::vector<std::vector<std::wstring>> strVector, std::wstring split); 47 void GetCommonPronunciation( 48 std::wstring &chineseCharacter, std::vector<std::wstring> &initials, std::vector<std::wstring> &nameFullFights); 49 std::vector<std::vector<std::wstring>> GetCombinedVector(std::vector<std::vector<std::wstring>> sourceVector); 50 std::wstring StringToWstring(std::string str); 51 std::string WstringToString(std::wstring str); 52 }; 53 } // namespace Contacts 54 } // namespace OHOS 55 #endif // CHARACTER_TRANSLITERATE_H 56