43static_assert(
sizeof(
T_Utf32) == 4);
44static_assert(
sizeof(
T_Utf16) == 2);
45static_assert(
sizeof(
T_Utf8) == 1);
71 int lastError() const noexcept {
return m_GetQ.empty()? m_ErrCode: 1; }
83 const char *buffer() const noexcept;
84 T_Utf16 getUtf16(
size_t pos,
bool reverseWord) const;
85 T_Utf32 getUtf32(
size_t pos,
bool reverseWord) const;
86 void pop(
size_t bytes);
87 void read(
size_t bytes);
89 size_t size() const noexcept;
95 std::
string m_ReadBuf;
105 iconv_t m_iconv{(iconv_t)-1};
110 bool guessCodePage();
115 void readReverseUTF16();
116 void readReverseUTF32();
118 bool readUTF16(C_Source &src,
bool reverseWord);
120 bool readUTF32(C_Source &src,
bool reverseWord);
139 size = std::char_traits<T>::length(ps);
141 std::string_view view_as_chars{
reinterpret_cast<const char*
>(ps), size*
sizeof(T)};
147 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
153 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
158std::basic_string<T>
BOM(
const std::basic_string<T> &s)
160 if constexpr (
sizeof(T) > 1)
161 return T(0xFEFF) + s;
163 return (
const T*)u8
"\uFEFF" + s;
166std::basic_string<T>
BOM(std::basic_string_view<T> sv)
168 if constexpr (
sizeof(T) > 1)
169 return T(0xFEFF) + std::basic_string<T>(sv);
171 return std::basic_string<T>{(
const T*)u8
"\uFEFF"}.append(sv);
174std::basic_string<T>
BOM(
const T *p)
176 if constexpr (
sizeof(T) > 1)
177 return T(0xFEFF) + std::basic_string<T>(p);
179 return std::basic_string<T>{(
const T*)u8
"\uFEFF"} += p;
188static_assert(
sizeof(
T_Utf32) == 4);
189static_assert(
sizeof(
T_Utf16) == 2);
190static_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.