xref: /base/telephony/sms_mms/utils/string_utils.h (revision e5d0e473)
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
16#ifndef STRING_UTILS_H
17#define STRING_UTILS_H
18
19#include <string>
20#include <vector>
21
22#include "cstdint"
23#include "iosfwd"
24namespace OHOS {
25namespace Telephony {
26class StringUtils {
27public:
28    static std::string StringToHex(const std::string &data);
29    static std::string HexToString(const std::string &str);
30    static std::string StringToHex(const char *data, int byteLength);
31    static std::string ToUtf8(const std::u16string &str16);
32    static std::u16string ToUtf16(const std::string &str);
33    static std::string StringToHex(const std::vector<uint8_t> &data);
34    static std::vector<uint8_t> HexToByteVector(const std::string &str);
35    static bool IsEmpty(const std::string &str);
36
37private:
38    StringUtils();
39    virtual ~StringUtils();
40    static uint16_t HexCharToInt(char c);
41};
42} // namespace Telephony
43} // namespace OHOS
44#endif