Compare commits

...

5 Commits

3 changed files with 7 additions and 40 deletions

View File

@ -367,7 +367,8 @@ namespace NSDocxRenderer
bForcedBold,
m_bUseDefaultFont,
m_bWriteStyleRaw,
m_bCollectMetaInfo
m_bCollectMetaInfo,
m_bFontSubstitution
);
}

View File

@ -100,45 +100,8 @@ const std::vector<std::string> TxtFile::readUtf8Lines(int IdxEncoding)
{
unicode_content = conv.toUnicode(file_data.get(), read_size, 65001);
}
#if !defined(_WIN32) && !defined(_WIN64)
std::wstring regular_text;
std::string utf8_result;
for (size_t i = 0; i < unicode_content.size(); i++)
{
unsigned int cp = static_cast<unsigned int>(unicode_content[i]);
if (cp > 0xFFFF)
{
if (!regular_text.empty())
{
utf8_result += conv.fromUnicode(regular_text, "UTF-8");
regular_text.clear();
}
utf8_result += static_cast<char>(0xF0 | ((cp >> 18) & 0x07));
utf8_result += static_cast<char>(0x80 | ((cp >> 12) & 0x3F));
utf8_result += static_cast<char>(0x80 | ((cp >> 6) & 0x3F));
utf8_result += static_cast<char>(0x80 | (cp & 0x3F));
}
else
{
regular_text += unicode_content[i];
}
}
if (!regular_text.empty())
{
utf8_result += conv.fromUnicode(regular_text, "UTF-8");
}
utf8_content = utf8_result;
#else
utf8_content = conv.fromUnicode(unicode_content, "UTF-8");
#endif
}
size_t lineCount = 0;
if (!utf8_content.empty())

View File

@ -105,6 +105,8 @@ namespace NSUnicodeConverter
UErrorCode status = U_ZERO_ERROR;
int32_t nUCharCapacity = (int32_t)nInputLen;// UTF-16 uses 2 code-points per char
if (sizeof(wchar_t) > 2)
nUCharCapacity *= 2;
UChar* pUChar = new UChar[(uint32_t)nUCharCapacity * sizeof(UChar)];
if (pUChar)
@ -169,8 +171,9 @@ namespace NSUnicodeConverter
if (U_SUCCESS(status))
{
int32_t nUCharCapacity = (int32_t)nInputLen;// UTF-16 uses 2 code-points per char
if (sizeof(wchar_t) > 2)
nUCharCapacity *= 2;
//UChar* pUChar = new UChar[nUCharCapacity];
UChar* pUChar = (UChar*)malloc((uint32_t)nUCharCapacity * sizeof(UChar));
if (pUChar)
{
@ -196,7 +199,7 @@ namespace NSUnicodeConverter
sRes.clear();
}
}
//delete []pUCharStart;
free(pUChar);
}
ucnv_close(conv);
}