From bfe40a66673290e66a19179e9b711274e0b3078f Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Wed, 6 May 2009 19:14:10 +0000 Subject: [PATCH] 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. --- aegisub/src/text_file_writer.cpp | 10 +++++++++- aegisub/src/text_file_writer.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/aegisub/src/text_file_writer.cpp b/aegisub/src/text_file_writer.cpp index 4ccdb6d94..19982548a 100644 --- a/aegisub/src/text_file_writer.cpp +++ b/aegisub/src/text_file_writer.cpp @@ -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"); diff --git a/aegisub/src/text_file_writer.h b/aegisub/src/text_file_writer.h index 4e6a3c488..0de541eb2 100644 --- a/aegisub/src/text_file_writer.h +++ b/aegisub/src/text_file_writer.h @@ -42,6 +42,7 @@ // Headers #include #include +#include #include