From 6eb5ade55c3b6a5f98ceeca0b74bdcd8f8af6400 Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Sat, 25 Jul 2020 16:33:24 +0800 Subject: [PATCH] Use the same default encoding to read and write file (Bug #234) --- ChangeLog | 1 + src/xmlcopyeditor.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index cb0f702..e609908 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ # Version number followed by the release date 1.2.1.5 + * Use the same default encoding to read and write file (Bug #234) * Only show SSE2 warning in debug build * Bug #228 Misleading translation when file was changed externally, may lead to data loss * Bug #227 Dead Link: Help > Forum diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index af58997..46a6bb2 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -3139,7 +3139,11 @@ bool MyFrame::openFile ( const wxString &file, bool largeFile ) es.parse ( docBuffer, docBufferLen ); encoding = es.getEncoding(); if ( encoding.empty() ) // Expat couldn't parse file (e.g. UTF-32) + { encoding = getApproximateEncoding ( docBuffer, docBufferLen ); + if ( encoding.empty() ) + encoding = "UTF-8"; + } } // convert buffer if not UTF-8