Fixed file backup AGAIN...

Originally committed to SVN as r1279.
This commit is contained in:
Rodrigo Braz Monteiro 2007-06-21 04:11:24 +00:00
parent cf710ffd90
commit 1db207ea29
2 changed files with 4 additions and 3 deletions

View File

@ -557,7 +557,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
// Make sure that file isn't actually a timecode file
TextFileReader testSubs(filename);
isBinary = testSubs.GetCurrentEncoding() == _T("binary");
if (testSubs.HasMoreLines()) {
if (!isBinary && testSubs.HasMoreLines()) {
wxString cur = testSubs.ReadLineFromFile();
if (cur.Left(10) == _T("# timecode")) {
LoadVFR(filename);

View File

@ -62,6 +62,7 @@ TextFileReader::TextFileReader(wxString _filename,wxString enc,bool _trim) {
// Set encoding
encoding = enc;
if (encoding.IsEmpty()) encoding = GetEncoding(filename);
if (encoding == _T("binary")) return;
SetEncodingConfiguration();
}
@ -127,8 +128,8 @@ wxString TextFileReader::GetEncoding(const wxString _filename) {
else if (b[0] == 0x2B && b[1] == 0x2F && b[2] == 0x76) return _T("UTF-7");
// Try to guess UTF-16
else if (b[0] == 0x00 && b[2] == 0x00) return _T("UTF-16BE");
else if (b[1] == 0x00 && b[3] == 0x00) return _T("UTF-16LE");
else if (b[0] == 0 && b[1] >= 32 && b[2] == 0 && b[3] >= 32) return _T("UTF-16BE");
else if (b[0] >= 32 && b[1] == 0 && b[2] >= 32 && b[3] == 0) return _T("UTF-16LE");
// If any of the first four bytes are under 0x20 (the first printable character),
// except for 9-13 range, assume binary