fix: fix fatal error in encoding/iconv.
- fix the size of input data error (forget mul with the size of unit) - fix the wrong code name for UTF16 and UTF32. - fix wrong assign for `outbytesleft`.
This commit is contained in:
@ -151,7 +151,7 @@ namespace yycc::encoding::iconv {
|
|||||||
|
|
||||||
// resize for container and its variables
|
// resize for container and its variables
|
||||||
str_to.resize(str_to.size() + ICONV_INC_LEN);
|
str_to.resize(str_to.size() + ICONV_INC_LEN);
|
||||||
outbytesleft = str_to.size();
|
outbytesleft += ICONV_INC_LEN;
|
||||||
|
|
||||||
// assign new outbuf from failed position
|
// assign new outbuf from failed position
|
||||||
outbuf = reinterpret_cast<char*>(str_to.data()) + len;
|
outbuf = reinterpret_cast<char*>(str_to.data()) + len;
|
||||||
@ -193,15 +193,15 @@ namespace yycc::encoding::iconv {
|
|||||||
constexpr auto WCHAR_CODENAME_LITERAL = "WCHAR_T"sv;
|
constexpr auto WCHAR_CODENAME_LITERAL = "WCHAR_T"sv;
|
||||||
constexpr auto UTF16_CODENAME_LITERAL =
|
constexpr auto UTF16_CODENAME_LITERAL =
|
||||||
#if defined(YYCC_ENDIAN_LITTLE)
|
#if defined(YYCC_ENDIAN_LITTLE)
|
||||||
"UTF16LE"sv;
|
"UTF-16LE"sv;
|
||||||
#else
|
#else
|
||||||
"UTF16BE"sv;
|
"UTF-16BE"sv;
|
||||||
#endif
|
#endif
|
||||||
constexpr auto UTF32_CODENAME_LITERAL =
|
constexpr auto UTF32_CODENAME_LITERAL =
|
||||||
#if defined(YYCC_ENDIAN_LITTLE)
|
#if defined(YYCC_ENDIAN_LITTLE)
|
||||||
"UTF32LE"sv;
|
"UTF-32LE"sv;
|
||||||
#else
|
#else
|
||||||
"UTF32BE"sv;
|
"UTF-32BE"sv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
@ -210,7 +210,7 @@ namespace yycc::encoding::iconv {
|
|||||||
// We call them VecString and VecStringView, and use them in "iconv_kernel" instead of real std::vector.
|
// We call them VecString and VecStringView, and use them in "iconv_kernel" instead of real std::vector.
|
||||||
// They exposed interface are std::vector-like but its inner is std::basic_string and std::basic_string_view.
|
// They exposed interface are std::vector-like but its inner is std::basic_string and std::basic_string_view.
|
||||||
#define USER_CONVFN(src_char_type, dst_char_type) \
|
#define USER_CONVFN(src_char_type, dst_char_type) \
|
||||||
auto rv = iconv_kernel(this->token, reinterpret_cast<const uint8_t*>(src.data()), src.size()); \
|
auto rv = iconv_kernel(this->token, reinterpret_cast<const uint8_t*>(src.data()), src.size() * sizeof(src_char_type)); \
|
||||||
if (rv.has_value()) { \
|
if (rv.has_value()) { \
|
||||||
const auto& dst = rv.value(); \
|
const auto& dst = rv.value(); \
|
||||||
if constexpr (sizeof(dst_char_type) > 1u) { \
|
if constexpr (sizeof(dst_char_type) > 1u) { \
|
||||||
|
Reference in New Issue
Block a user