2023-02-10 16:17:17 +08:00
|
|
|
#pragma once
|
2023-02-11 15:29:51 +08:00
|
|
|
#include "VTUtils.hpp"
|
2023-02-10 16:17:17 +08:00
|
|
|
#include <string>
|
2024-08-16 22:07:23 +08:00
|
|
|
#include <string_view>
|
2023-02-10 16:17:17 +08:00
|
|
|
|
2023-02-26 21:48:03 +08:00
|
|
|
namespace LibCmo::EncodingHelper {
|
2023-02-10 16:17:17 +08:00
|
|
|
|
2024-08-16 22:07:23 +08:00
|
|
|
using EncodingToken = void*;
|
|
|
|
constexpr EncodingToken INVALID_ENCODING_TOKEN = nullptr;
|
2023-02-25 22:58:28 +08:00
|
|
|
|
2024-08-16 22:07:23 +08:00
|
|
|
EncodingToken CreateEncodingToken(const std::u8string_view& enc_name);
|
|
|
|
void DestroyEncodingToken(EncodingToken token);
|
2023-02-25 22:58:28 +08:00
|
|
|
|
2024-08-16 22:07:23 +08:00
|
|
|
bool ToOrdinary(const std::u8string_view& src, std::string& dst, EncodingToken token);
|
|
|
|
bool ToOrdinary(const char8_t* src, std::string& dst, EncodingToken token);
|
|
|
|
std::string ToOrdinary(const std::u8string_view& src, EncodingToken token);
|
|
|
|
std::string ToOrdinary(const char8_t* src, EncodingToken token);
|
2023-02-10 16:17:17 +08:00
|
|
|
|
2024-08-16 22:07:23 +08:00
|
|
|
bool ToUTF8(const std::string_view& src, std::u8string& dst, EncodingToken token);
|
|
|
|
bool ToUTF8(const char* src, std::u8string& dst, EncodingToken token);
|
|
|
|
std::u8string ToUTF8(const std::string_view& src, EncodingToken token);
|
|
|
|
std::u8string ToUTF8(const char* src, EncodingToken token);
|
2023-02-10 16:17:17 +08:00
|
|
|
|
|
|
|
}
|