diff --git a/libaegisub/common/charset_conv.cpp b/libaegisub/common/charset_conv.cpp index 514f364ec4..b0825e0194 100644 --- a/libaegisub/common/charset_conv.cpp +++ b/libaegisub/common/charset_conv.cpp @@ -358,38 +358,6 @@ size_t IconvWrapper::Convert(std::string_view source, std::span dest) { return dest.size() - dstLen; } -size_t IconvWrapper::RequiredBufferSize(std::string_view str) { - return RequiredBufferSize(str.data(), str.size()); -} - -size_t IconvWrapper::RequiredBufferSize(const char* src, size_t srcLen) { - char buff[4096]; - size_t charsWritten = 0; - size_t res; - - do { - char* dst = buff; - size_t dstSize = sizeof(buff); - res = conv->Convert(&src, &srcLen, &dst, &dstSize); - conv->Convert(nullptr, nullptr, &dst, &dstSize); - - charsWritten += dst - buff; - } while (res == iconv_failed && errno == E2BIG); - - if (res == iconv_failed) { - switch (errno) { - case EINVAL: - case EILSEQ: - throw BadInput( - "One or more characters in the input string were not valid " - "characters in the given input encoding"); - default: - throw ConversionFailure("An unknown conversion failure occurred"); - } - } - return charsWritten; -} - bool IsConversionSupported(const char *src, const char *dst) { iconv_t cd = iconv_open(dst, src); bool supported = cd != iconv_invalid; diff --git a/libaegisub/include/libaegisub/charset_conv.h b/libaegisub/include/libaegisub/charset_conv.h index 9f2a9ddfb9..29a6b52c47 100644 --- a/libaegisub/include/libaegisub/charset_conv.h +++ b/libaegisub/include/libaegisub/charset_conv.h @@ -93,16 +93,6 @@ class IconvWrapper { /// @param[out] dest Buffer to place the result in /// @return Number of bytes written to dest size_t Convert(std::string_view source, std::span dest); - - /// @brief Get the required buffer size required to fit the source string in the target charset - /// @param source A string in the source charset - /// @param sourceSize Length of the source in bytes - /// @return Bytes required, including NUL terminator if applicable - size_t RequiredBufferSize(const char* source, size_t sourceSize); - /// @brief Get the required buffer size required to fit the source string in the target charset - /// @param str A string in the source charset - /// @return Bytes required, not including space needed for NUL terminator - size_t RequiredBufferSize(std::string_view str); }; /// Is the conversion from src to dst supported by the linked iconv library?