void SetAppendFiles(bool bAppendFiles);
void SetPaths(const PathContext &files, bool tempPaths);
void SetAlternativePaths(const PathContext &altPaths);
- void SetCodepage(int codepage) { m_codepage = codepage; }
bool RunFileDiff();
void GetDiffStatus(DIFFSTATUS *status) const;
void AddDiffRange(DiffList *pDiffList, unsigned begin0, unsigned end0, unsigned begin1, unsigned end1, OP_TYPE op);
bool m_bAddCmdLine; /**< Do we add commandline to patch file? */
bool m_bAppendFiles; /**< Do we append to existing patch file? */
int m_nDiffs; /**< Difference count */
- int m_codepage; /**< Codepage used in line filter */
DiffList *m_pDiffList; /**< Pointer to external DiffList */
std::unique_ptr<MovedLines> m_pMovedLines[3];
const FilterCommentsManager* m_pFilterCommentsManager; /**< Comments filtering manager */
_T ("\x0d") // Macintosh style
};
-static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, bool bForceUTF8, int nStartLine = 0, int nLines = -1);
+static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine = 0, int nLines = -1);
/////////////////////////////////////////////////////////////////////////////
// CMergeDoc
* (the plugins are optional, not the conversion)
* @todo Show SaveToFile() errors?
*/
-static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, bool bForceUTF8, int nStartLine, int nLines)
+static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, int nStartLine, int nLines)
{
- ASSERT(buf.m_nSourceEncoding == buf.m_nDefaultEncoding);
- int orig_codepage = buf.getCodepage();
- ucr::UNICODESET orig_unicoding = buf.getUnicoding();
- bool orig_bHasBOM = buf.getHasBom();
-
- // If file was in Unicode
- if (orig_unicoding != ucr::NONE || bForceUTF8)
- {
- // we subvert the buffer's memory of the original file encoding
- buf.setUnicoding(ucr::UTF8); // write as UTF-8 (for preprocessing)
- buf.setCodepage(ucr::CP_UTF_8); // should not matter
- buf.setHasBom(false);
- }
-
// and we don't repack the file
PackingInfo * tempPacker = nullptr;
String sError;
int retVal = buf.SaveToFile(filepath, true, sError, tempPacker,
CRLF_STYLE_AUTOMATIC, false, nStartLine, nLines);
-
- // restore memory of encoding of original file
- buf.setUnicoding(orig_unicoding);
- buf.setCodepage(orig_codepage);
- buf.setHasBom(orig_bHasBOM);
}
/**
// Set up DiffWrapper
m_diffWrapper.GetOptions(&diffOptions);
- bool bForceUTF8 = diffOptions.bIgnoreCase;
- if (std::any_of(m_ptBuf, m_ptBuf + m_nBuffers,
- [&](auto& ptBuf) { return m_ptBuf[0]->getCodepage() != ptBuf->getCodepage() || ptBuf->getUnicoding() != ucr::NONE; }))
- bForceUTF8 = true;
-
// Clear diff list
m_diffList.Clear();
m_nCurDiff = -1;
else
m_diffWrapper.SetPaths(PathContext(m_tempFiles[0].GetPath(), m_tempFiles[1].GetPath(), m_tempFiles[2].GetPath()), true);
m_diffWrapper.SetCompareFiles(m_filePaths);
- m_diffWrapper.SetCodepage(bForceUTF8 ? ucr::CP_UTF_8 : (m_ptBuf[0]->m_encoding.m_unicoding ? CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage));
DIFFSTATUS status;
for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
{
m_ptBuf[nBuffer]->SetTempPath(tempPath);
- SaveBuffForDiff(*m_ptBuf[nBuffer], m_tempFiles[nBuffer].GetPath(), bForceUTF8);
+ SaveBuffForDiff(*m_ptBuf[nBuffer], m_tempFiles[nBuffer].GetPath());
}
m_diffWrapper.SetCreateDiffList(&m_diffList);
{
nLines[nBuffer] = (i >= syncpoints.size()) ? -1 : syncpoints[i][nBuffer] - nStartLine[nBuffer];
m_ptBuf[nBuffer]->SetTempPath(tempPath);
- SaveBuffForDiff(*m_ptBuf[nBuffer], m_tempFiles[nBuffer].GetPath(), bForceUTF8,
+ SaveBuffForDiff(*m_ptBuf[nBuffer], m_tempFiles[nBuffer].GetPath(),
nStartLine[nBuffer], nLines[nBuffer]);
}
DiffList templist;