chore: remove unused Unicode::UTF32ToUTF8

This commit is contained in:
sithlord48
2025-12-02 20:55:45 -05:00
committed by Nick Bolton
parent bfc65ebf6b
commit 6174043c7f
4 changed files with 0 additions and 70 deletions

View File

@ -227,16 +227,6 @@ std::string Unicode::UTF16ToUTF8(const std::string_view &src, bool *errors)
return doUTF16ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
}
std::string Unicode::UTF32ToUTF8(const std::string_view &src, bool *errors)
{
// default to success
resetError(errors);
// convert
uint32_t n = (uint32_t)src.size() >> 2;
return doUTF32ToUTF8(reinterpret_cast<const uint8_t *>(src.data()), n, errors);
}
std::string Unicode::doUCS2ToUTF8(const uint8_t *data, uint32_t n, bool *errors)
{
// make some space
@ -368,48 +358,6 @@ std::string Unicode::doUTF16ToUTF8(const uint8_t *data, uint32_t n, bool *errors
return dst;
}
std::string Unicode::doUTF32ToUTF8(const uint8_t *data, uint32_t n, bool *errors)
{
// make some space
std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
bool byteSwapped = false;
if (n >= 1) {
switch (decode32(data, false)) {
case 0x0000feff:
data += 4;
--n;
break;
case 0x0000fffe:
byteSwapped = true;
data += 4;
--n;
break;
default:
break;
}
}
#ifdef WORDS_BIGENDIAN
byteSwapped = !byteSwapped;
#endif
// convert each character
for (; n > 0; --n) {
auto c = decode32(data, byteSwapped);
if (c >= 0x00110000) {
setError(errors);
c = s_replacement;
}
toUTF8(dst, c, errors);
data += 4;
}
return dst;
}
uint32_t Unicode::fromUTF8(const uint8_t *&data, uint32_t &n)
{
assert(data != nullptr);

View File

@ -81,13 +81,6 @@ public:
*/
static std::string UTF16ToUTF8(const std::string_view &, bool *errors = nullptr);
//! Convert from UTF-32 to UTF-8
/*!
Convert from UTF-32 to UTF-8. If errors is not nullptr then *errors is
set to true iff any character could not be decoded.
*/
static std::string UTF32ToUTF8(const std::string_view &, bool *errors = nullptr);
//@}
private:
@ -95,7 +88,6 @@ private:
static std::string doUCS2ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
static std::string doUCS4ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
static std::string doUTF16ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
static std::string doUTF32ToUTF8(const uint8_t *src, uint32_t n, bool *errors);
// convert characters to/from UTF8
static uint32_t fromUTF8(const uint8_t *&src, uint32_t &size);

View File

@ -14,15 +14,6 @@ void UnicodeTests::initTestCase()
m_log.setFilter(LogLevel::Debug2);
}
void UnicodeTests::UTF32ToUTF8()
{
bool errors;
auto result = Unicode::UTF32ToUTF8(std::string("h\0\0\0e\0\0\0l\0\0\0l\0\0\0o\0\0\0", 20), &errors);
QVERIFY(!errors);
QCOMPARE(result.c_str(), "hello");
}
void UnicodeTests::UTF16ToUTF8()
{
bool errors;

View File

@ -13,7 +13,6 @@ class UnicodeTests : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void UTF32ToUTF8();
void UTF16ToUTF8();
private: