1 /*
2  * Copyright (C) 2024 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 STRING_UTILS_H
17 #define STRING_UTILS_H
18 #ifdef FEATURE_GNSS_SUPPORT
19 
20 #include <string>
21 #include <vector>
22 
23 #include "cstdint"
24 #include "iosfwd"
25 
26 namespace OHOS {
27 namespace Location {
28 class StringUtils {
29 public:
30     static std::string StringToHex(const std::string &data);
31     static std::string HexToString(const std::string &str);
32     static std::string StringToHex(const char *data, int byteLength);
33     static std::string ToUtf8(const std::u16string &str16);
34     static std::u16string ToUtf16(const std::string &str);
35     static std::string StringToHex(const std::vector<uint8_t> &data);
36     static std::vector<uint8_t> HexToByteVector(const std::string &str);
37     static std::wstring Utf8ToWstring(const std::string &utf8Str);
38     static std::wstring Ucs2ToWstring(const std::string &ucs2Str);
39     static std::string WstringToString(const std::string &wStr);
40     static std::string WstringToString(const std::wstring& wStr);
41     static std::string Gsm7Decode(const std::string &gsm7Str);
42 
43 private:
44     StringUtils();
45     virtual ~StringUtils();
46     static uint16_t HexCharToInt(char c);
47 };
48 } // namespace Location
49 } // namespace OHOS
50 #endif // FEATURE_GNSS_SUPPORT
51 #endif // STRING_UTILS_H