44static_assert(
sizeof(
T_Utf32) == 4);
45static_assert(
sizeof(
T_Utf16) == 2);
46static_assert(
sizeof(
T_Utf8) == 1);
72 int lastError() const noexcept {
return m_GetQ.empty()? m_ErrCode: 1; }
85 const char *buffer() const noexcept;
86 T_Utf16 getUtf16(
size_t pos,
bool reverseWord) const;
87 T_Utf32 getUtf32(
size_t pos,
bool reverseWord) const;
88 void pop(
size_t bytes);
89 void read(
size_t bytes);
91 size_t size() const noexcept;
97 std::
string m_ReadBuf;
107 iconv_t m_iconv{(iconv_t)-1};
110 bool m_BOMed =
false;
113 bool guessCodePage();
118 void readReverseUTF16();
119 void readReverseUTF32();
121 bool readUTF16(C_Source &src,
bool reverseWord);
123 bool readUTF32(C_Source &src,
bool reverseWord);
142 size = std::char_traits<T>::length(ps);
144 std::string_view view_as_chars{
reinterpret_cast<const char*
>(ps), size*
sizeof(T)};
150 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
156 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
161std::basic_string<T>
BOM(
const std::basic_string<T> &s)
163 if constexpr (
sizeof(T) > 1)
164 return T(0xFEFF) + s;
166 return (
const T*)u8
"\uFEFF" + s;
169std::basic_string<T>
BOM(std::basic_string_view<T> sv)
171 if constexpr (
sizeof(T) > 1)
172 return T(0xFEFF) + std::basic_string<T>(sv);
174 return std::basic_string<T>{(
const T*)u8
"\uFEFF"}.append(sv);
177std::basic_string<T>
BOM(
const T *p)
179 if constexpr (
sizeof(T) > 1)
180 return T(0xFEFF) + std::basic_string<T>(p);
182 return std::basic_string<T>{(
const T*)u8
"\uFEFF"} += p;
191static_assert(
sizeof(
T_Utf32) == 4);
192static_assert(
sizeof(
T_Utf16) == 2);
193static_assert(
sizeof(
T_Utf8) == 1);
C_UnicodeIn(std::string &&s, T_Encoding codepage=0)=delete
C_UnicodeIn(const char *s, T_Encoding codepage=0)
T_Encoding encoding() const noexcept
C_UnicodeIn(FH_ReadChar &&readc, T_Encoding codepage=0)
int lastError() const noexcept
THE common namespace of bux library.
std::string_view to_utf8(T_Utf32 uc)
const char *const * T_Encoding
std::basic_string< T > BOM(const std::basic_string< T > &s)
std::function< std::optional< char >()> FH_ReadChar
void read(const std::string &src, size_t &off, T &data) noexcept
const T_Encoding ENCODING_UTF8
std::uint16_t T_Utf16
UTF-16: You need T_Utf16[2] to hold full range of unicode.
std::uint8_t T_Utf8
UTF-8: You need T_Utf8[4] to hold full range of unicode.
@ UIE_NO_UNICODE_TRANSLATION
std::uint32_t T_Utf32
UTF-32 to cover the full range of codespace U+0000 ~ U+10FFFF.