mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Minor refact (Logic/SubtitleFormats/SubtitleFormat)
This commit is contained in:
parent
393dc2c0e9
commit
7259bdcef7
@ -301,7 +301,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public int ErrorCount
|
||||
{
|
||||
get { return _errorCount; }
|
||||
get
|
||||
{
|
||||
return _errorCount;
|
||||
}
|
||||
}
|
||||
|
||||
abstract public bool IsMine(List<string> lines, string fileName);
|
||||
@ -312,7 +315,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public bool IsVobSubIndexFile
|
||||
{
|
||||
get { return string.CompareOrdinal(Extension, ".idx") == 0; }
|
||||
get
|
||||
{
|
||||
return string.CompareOrdinal(Extension, ".idx") == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat)
|
||||
@ -363,35 +369,21 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public bool BatchMode { get; set; }
|
||||
|
||||
public static string ToUtf8XmlString(XmlDocument xml, bool omitXmlDeclaration)
|
||||
public static string ToUtf8XmlString(XmlDocument xml, bool omitXmlDeclaration = false)
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
settings.Encoding = new UnicodeEncoding(false, false); // no BOM in a .NET string
|
||||
settings.Indent = true;
|
||||
settings.OmitXmlDeclaration = omitXmlDeclaration;
|
||||
|
||||
StringWriter textWriter = null;
|
||||
try
|
||||
var settings = new XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
OmitXmlDeclaration = omitXmlDeclaration,
|
||||
};
|
||||
var result = new StringBuilder();
|
||||
|
||||
using (var xmlWriter = XmlWriter.Create(result, settings))
|
||||
{
|
||||
textWriter = new StringWriter();
|
||||
var xmlWriter = XmlWriter.Create(textWriter, settings);
|
||||
xml.Save(xmlWriter);
|
||||
xmlWriter.Flush();
|
||||
return textWriter.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (textWriter != null)
|
||||
{
|
||||
textWriter.Dispose();
|
||||
textWriter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToUtf8XmlString(XmlDocument xml)
|
||||
{
|
||||
return ToUtf8XmlString(xml, false);
|
||||
return result.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim();
|
||||
}
|
||||
|
||||
public virtual bool IsTextBased
|
||||
|
Loading…
Reference in New Issue
Block a user