#ifndef BASE_INCLUDE_STRING_UNICODE_DECODE_UTILS_H_
#define BASE_INCLUDE_STRING_UNICODE_DECODE_UTILS_H_
#include <cstddef>
#include <cstdint>
#include <string>
#include <string_view>
#include "base/include/base_export.h"
namespace lynx::base {
enum class UnicodeDecodeProperty : uint8_t {
kDefault,
kInsertZeroWidthChar,
kCjkInsertWordJoiner,
};
class UnicodeDecodeUtils {
public:
BASE_EXPORT static std::string Decode(
std::string_view input_string,
UnicodeDecodeProperty property = UnicodeDecodeProperty::kDefault);
private:
static int ConvertUnicode(uint32_t unicode, char* buffer);
static const char* DecodeEntity(std::string_view entity);
static bool IsCJK(uint32_t character);
static const char* ReverseFindUnicodeCharFirstByte(const char* base,
std::size_t length);
static uint32_t ConvertU8ToU32Char(const char* char_start, std::size_t length,
const char** end);
static bool IsCharStartByte(char c);
static void ProcessInsertChar(std::string* output_ptr,
UnicodeDecodeProperty property);
};
}
#endif