Fix a bug (in a somewhat questionable manner) that would cause the text file writer to occasionally think the system locale was Unicode when it wasn't (by using an uninitialized variable in a condition). Should fix the issue with the SRT export filter failing to write "1" on the first line when using "local" as the text encoding.

Originally committed to SVN as r2904.
This commit is contained in:
Karl Blomster 2009-05-06 19:14:10 +00:00
parent 1e2a031765
commit 4d83215690
2 changed files with 10 additions and 1 deletions

View File

@ -54,7 +54,15 @@ TextFileWriter::TextFileWriter(wxString _filename,wxString enc) {
// Set encoding
encoding = enc;
if (encoding == _T("Local") || (encoding.IsEmpty() && Options.AsText(_T("Save Charset")).Lower() == _T("local"))) conv = &wxConvLocal;
if (encoding == _T("Local") || (encoding.IsEmpty() && Options.AsText(_T("Save Charset")).Lower() == _T("local"))) {
conv = &wxConvLocal;
wxFontEncoding sysenc = wxLocale::GetSystemEncoding();
if (sysenc == wxFONTENCODING_UTF8 || sysenc == wxFONTENCODING_UTF7 ||
sysenc == wxFONTENCODING_UNICODE) // that last one may be a bit questionable
IsUnicode = true;
else
IsUnicode = false;
}
else {
if (encoding.IsEmpty()) encoding = Options.AsText(_T("Save Charset"));
if (encoding == _T("US-ASCII")) encoding = _T("ISO-8859-1");

View File

@ -42,6 +42,7 @@
// Headers
#include <wx/wxprec.h>
#include <wx/string.h>
#include <wx/intl.h>
#include <fstream>