mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
fix UTF-16 fb2
This commit is contained in:
@ -1962,11 +1962,31 @@ HRESULT CFb2File::FromHtml(const std::wstring& sHtmlFile, const std::wstring& sC
|
||||
oDocument.WriteString(L"</version></document-info>");
|
||||
// body
|
||||
oDocument.WriteString(L"</description><body><section>");
|
||||
std::string sContent;
|
||||
NSFile::CFileBinary::ReadAllTextUtf8A(sHtmlFile, sContent);;
|
||||
|
||||
BYTE* pData;
|
||||
DWORD nLength;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(sHtmlFile, &pData, nLength))
|
||||
return S_FALSE;
|
||||
|
||||
std::string sContent = XmlUtils::GetUtf8FromFileContent(pData, nLength);
|
||||
bool bNeedConvert = true;
|
||||
if (nLength > 4)
|
||||
{
|
||||
if (pData[0] == 0xFF && pData[1] == 0xFE && !(pData[2] == 0x00 && pData[3] == 0x00))
|
||||
bNeedConvert = false;
|
||||
if (pData[0] == 0xFE && pData[1] == 0xFF)
|
||||
bNeedConvert = false;
|
||||
|
||||
if (pData[0] == 0xFF && pData[1] == 0xFE && pData[2] == 0x00 && pData[3] == 0x00)
|
||||
bNeedConvert = false;
|
||||
if (pData[0] == 0 && pData[1] == 0 && pData[2] == 0xFE && pData[3] == 0xFF)
|
||||
bNeedConvert = false;
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
|
||||
XmlUtils::CXmlLiteReader oIndexHtml;
|
||||
std::vector<std::wstring> arrBinary;
|
||||
std::wstring xhtml = htmlToXhtml(sContent, false); // ????
|
||||
std::wstring xhtml = htmlToXhtml(sContent, bNeedConvert);
|
||||
if (oIndexHtml.FromString(xhtml))
|
||||
{
|
||||
oIndexHtml.ReadNextNode(); // html
|
||||
|
||||
Reference in New Issue
Block a user