67 int lastError() const noexcept {
return m_GetQ.empty()? m_ErrCode: 1; }
79 const char *buffer() const noexcept;
80 T_Utf16 getUtf16(
size_t pos,
bool reverseWord) const;
81 T_Utf32 getUtf32(
size_t pos,
bool reverseWord) const;
82 void pop(
size_t bytes);
83 void read(
size_t bytes);
85 size_t size() const noexcept;
91 std::
string m_ReadBuf;
101 iconv_t m_iconv{(iconv_t)-1};
106 bool guessCodePage();
111 void readReverseUTF16();
112 void readReverseUTF32();
114 bool readUTF16(C_Source &src,
bool reverseWord);
116 bool readUTF32(C_Source &src,
bool reverseWord);
135 size = std::char_traits<T>::length(ps);
137 std::string_view view_as_chars{
reinterpret_cast<const char*
>(ps), size*
sizeof(T)};
143 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
149 std::string_view view_as_chars{
reinterpret_cast<const char*
>(s.data()), s.size()*
sizeof(T)};
154std::basic_string<T>
BOM(std::basic_string_view<T> sv)
156 if constexpr (
sizeof(T) > 1)
157 return T(0xFEFF) + std::basic_string<T>(sv);
159 return std::basic_string<T>{(
const T*)u8
"\uFEFF"}.append(sv);
162std::basic_string<T>
BOM(
const T *p)
164 if constexpr (
sizeof(T) > 1)
165 return T(0xFEFF) + std::basic_string<T>(p);
167 return std::basic_string<T>{(
const T*)u8
"\uFEFF"} += p;
176static_assert(
sizeof(
T_Utf32) == 4);
177static_assert(
sizeof(
T_Utf16) == 2);
178static_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::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::basic_string< T > BOM(std::basic_string_view< T > sv)
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.