Changes to store the file encoding of loaded files, so that they can be saved the same way. This means we'll need an 'export' feature to overide the setting.

This commit is contained in:
Ima Mechanique 2012-10-23 16:31:58 +00:00
parent 02fda552c0
commit a94055b6ab
2 changed files with 14 additions and 6 deletions

View file

@ -289,7 +289,7 @@ namespace LSLEditor
this.FullPathName = Path.GetFileName(strPath); this.FullPathName = Path.GetFileName(strPath);
else else
this.FullPathName = strPath; this.FullPathName = strPath;
this.numberedTextBoxUC1.TextBox.LoadFile(strPath); this.encodedAs = this.numberedTextBoxUC1.TextBox.LoadFile(strPath);
if (!this.IsScript) if (!this.IsScript)
return; return;

View file

@ -2228,8 +2228,9 @@ namespace LSLEditor
} }
} }
public new void LoadFile(string path) public new Encoding LoadFile(string path)
{ {
Encoding fileEncoding = null;
if (path.StartsWith("http://")) if (path.StartsWith("http://"))
{ {
System.Net.WebClient webClient = new System.Net.WebClient(); System.Net.WebClient webClient = new System.Net.WebClient();
@ -2240,14 +2241,21 @@ namespace LSLEditor
if (File.Exists(path)) if (File.Exists(path))
{ {
// TODO needs to be refactored to read the file in once and pass the byte array to be checked. // TODO needs to be refactored to read the file in once and pass the byte array to be checked.
Encoding fileEncoding = TextFileEncodingDetector.DetectTextFileEncoding(path, Encoding.UTF8); fileEncoding = TextFileEncodingDetector.DetectTextFileEncoding(path, Encoding.UTF8);
StreamReader sr = new StreamReader(path, fileEncoding); try
this.Text = sr.ReadToEnd(); {
sr.Close(); StreamReader sr = new StreamReader(path, fileEncoding);
this.Text = sr.ReadToEnd();
sr.Close();
}
catch
{
}
} }
} }
// Fresh files can not be dirty // Fresh files can not be dirty
ClearUndoStack(); ClearUndoStack();
return fileEncoding;
} }
} }
} }