mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
more minor performance fixes
This commit is contained in:
parent
fa5b9e4980
commit
cdf2b712e3
@ -189,13 +189,13 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
|
||||
// fix end spaces
|
||||
if (endIndex < Text.Length && !newText.EndsWith(" ") && Text[endIndex] != ' ')
|
||||
if (endIndex < Text.Length && !newText.EndsWith(" ", StringComparison.Ordinal) && Text[endIndex] != ' ')
|
||||
{
|
||||
bool lastWord = ";:]<.!?".Contains(Text[endIndex].ToString());
|
||||
if (!lastWord)
|
||||
Text = Text.Insert(endIndex, " ");
|
||||
}
|
||||
else if (endIndex < Text.Length && newText.EndsWith(" ") && Text[endIndex] == ' ')
|
||||
else if (endIndex < Text.Length && newText.EndsWith(" ", StringComparison.Ordinal) && Text[endIndex] == ' ')
|
||||
{
|
||||
Text = Text.Remove(endIndex, 1);
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (list.Count > 0)
|
||||
{
|
||||
string name = list[0];
|
||||
int start = name.LastIndexOf("[", StringComparison.Ordinal);
|
||||
int end = name.LastIndexOf("]", StringComparison.Ordinal);
|
||||
int start = name.LastIndexOf('[');
|
||||
int end = name.LastIndexOf(']');
|
||||
if (start > 0 && end > start)
|
||||
{
|
||||
start++;
|
||||
@ -118,8 +118,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (comboBoxDictionaries.Items.Count > 0)
|
||||
{
|
||||
string name = comboBoxDictionaries.SelectedItem.ToString();
|
||||
int start = name.LastIndexOf("[", StringComparison.Ordinal);
|
||||
int end = name.LastIndexOf("]", StringComparison.Ordinal);
|
||||
int start = name.LastIndexOf('[');
|
||||
int end = name.LastIndexOf(']');
|
||||
if (start >= 0 && end > start)
|
||||
{
|
||||
start++;
|
||||
|
@ -152,8 +152,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
get
|
||||
{
|
||||
string name = comboBoxDictionaries.SelectedItem.ToString();
|
||||
int start = name.LastIndexOf("[");
|
||||
int end = name.LastIndexOf("]");
|
||||
int start = name.LastIndexOf('[');
|
||||
int end = name.LastIndexOf(']');
|
||||
if (start >= 0 && end > start)
|
||||
{
|
||||
start++;
|
||||
|
@ -831,7 +831,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
}
|
||||
|
||||
if (text.Contains("("))
|
||||
text = text.Remove(0, text.IndexOf("(")).Trim();
|
||||
text = text.Remove(0, text.IndexOf('(')).Trim();
|
||||
text = text.TrimStart('(').TrimEnd(')').Trim();
|
||||
string[] arr = text.Split('x');
|
||||
width = int.Parse(arr[0]);
|
||||
@ -1475,7 +1475,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
var lineHeight = parameter.LineHeight; // (textSize.Height * 0.64f);
|
||||
while (i < text.Length)
|
||||
{
|
||||
if (text.Substring(i).ToLower().StartsWith("<font "))
|
||||
if (text.Substring(i).ToLower().StartsWith("<font ", StringComparison.Ordinal))
|
||||
{
|
||||
float addLeft = 0;
|
||||
int oldPathPointIndex = path.PointCount;
|
||||
@ -1520,7 +1520,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
string fontContent = text.Substring(i, endIndex);
|
||||
if (fontContent.Contains(" color="))
|
||||
{
|
||||
string[] arr = fontContent.Substring(fontContent.IndexOf(" color=") + 7).Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.Ordinal) + 7).Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
string fontColor = arr[0].Trim('\'').Trim('"').Trim('\'');
|
||||
@ -1546,7 +1546,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
i += endIndex;
|
||||
}
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</font>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("</font>", StringComparison.Ordinal))
|
||||
{
|
||||
if (text.Substring(i).ToLower().Replace("</font>", string.Empty).Length > 0)
|
||||
{
|
||||
@ -1594,7 +1594,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
}
|
||||
i += 6;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("<i>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("<i>", StringComparison.Ordinal))
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
@ -1604,7 +1604,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isItalic = true;
|
||||
i += 2;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</i>") && isItalic)
|
||||
else if (text.Substring(i).ToLower().StartsWith("</i>", StringComparison.Ordinal) && isItalic)
|
||||
{
|
||||
if (lastText.ToString().EndsWith(" ") && !sb.ToString().StartsWith(" "))
|
||||
{
|
||||
@ -1617,7 +1617,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isItalic = false;
|
||||
i += 3;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("<b>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("<b>", StringComparison.Ordinal))
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
@ -1627,7 +1627,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isBold = true;
|
||||
i += 2;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</b>") && isBold)
|
||||
else if (text.Substring(i).ToLower().StartsWith("</b>", StringComparison.Ordinal) && isBold)
|
||||
{
|
||||
if (lastText.ToString().EndsWith(" ") && !sb.ToString().StartsWith(" "))
|
||||
{
|
||||
@ -1695,8 +1695,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
parameter.P.Text = fontTag + parameter.P.Text;
|
||||
if (parameter.P.Text.Contains("<font ") && !parameter.P.Text.Contains("</font>"))
|
||||
{
|
||||
int start = parameter.P.Text.LastIndexOf("<font ");
|
||||
int end = parameter.P.Text.IndexOf(">", start);
|
||||
int start = parameter.P.Text.LastIndexOf("<font ", StringComparison.Ordinal);
|
||||
int end = parameter.P.Text.IndexOf('>', start);
|
||||
fontTag = parameter.P.Text.Substring(start, end - start + 1);
|
||||
}
|
||||
|
||||
@ -1895,7 +1895,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
|
||||
if (parameter.SimpleRendering)
|
||||
{
|
||||
if (text.StartsWith("<font ") && Utilities.CountTagInText(text, "<font") == 1)
|
||||
if (text.StartsWith("<font ", StringComparison.Ordinal) && Utilities.CountTagInText(text, "<font") == 1)
|
||||
{
|
||||
parameter.SubtitleColor = Utilities.GetColorFromFontString(text, parameter.SubtitleColor);
|
||||
}
|
||||
@ -2019,7 +2019,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
var lastText = new StringBuilder();
|
||||
while (i < text.Length)
|
||||
{
|
||||
if (text.Substring(i).ToLower().StartsWith("<font "))
|
||||
if (text.Substring(i).ToLower().StartsWith("<font ", StringComparison.Ordinal))
|
||||
{
|
||||
float addLeft = 0;
|
||||
int oldPathPointIndex = path.PointCount;
|
||||
@ -2054,7 +2054,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
path = new GraphicsPath();
|
||||
sb = new StringBuilder();
|
||||
|
||||
int endIndex = text.Substring(i).IndexOf(">", StringComparison.Ordinal);
|
||||
int endIndex = text.Substring(i).IndexOf('>');
|
||||
if (endIndex == -1)
|
||||
{
|
||||
i += 9999;
|
||||
@ -2071,7 +2071,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
try
|
||||
{
|
||||
colorStack.Push(c); // save old color
|
||||
if (fontColor.StartsWith("rgb("))
|
||||
if (fontColor.StartsWith("rgb(", StringComparison.Ordinal))
|
||||
{
|
||||
arr = fontColor.Remove(0, 4).TrimEnd(')').Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
|
||||
@ -2090,7 +2090,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
i += endIndex;
|
||||
}
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</font>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("</font>", StringComparison.Ordinal))
|
||||
{
|
||||
if (text.Substring(i).ToLower().Replace("</font>", string.Empty).Length > 0)
|
||||
{
|
||||
@ -2138,7 +2138,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
}
|
||||
i += 6;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("<i>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("<i>", StringComparison.Ordinal))
|
||||
{
|
||||
if (sb.ToString().Trim().Length > 0)
|
||||
{
|
||||
@ -2148,7 +2148,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isItalic = true;
|
||||
i += 2;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</i>") && isItalic)
|
||||
else if (text.Substring(i).ToLower().StartsWith("</i>", StringComparison.Ordinal) && isItalic)
|
||||
{
|
||||
if (lastText.ToString().EndsWith(" ") && !sb.ToString().StartsWith(" "))
|
||||
{
|
||||
@ -2161,7 +2161,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isItalic = false;
|
||||
i += 3;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("<b>"))
|
||||
else if (text.Substring(i).ToLower().StartsWith("<b>", StringComparison.Ordinal))
|
||||
{
|
||||
if (sb.ToString().Trim().Length > 0)
|
||||
{
|
||||
@ -2171,7 +2171,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isBold = true;
|
||||
i += 2;
|
||||
}
|
||||
else if (text.Substring(i).ToLower().StartsWith("</b>") && isBold)
|
||||
else if (text.Substring(i).ToLower().StartsWith("</b>", StringComparison.Ordinal) && isBold)
|
||||
{
|
||||
if (lastText.ToString().EndsWith(" ") && !sb.ToString().StartsWith(" "))
|
||||
{
|
||||
@ -2184,7 +2184,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
isBold = false;
|
||||
i += 3;
|
||||
}
|
||||
else if (text.Substring(i).StartsWith(Environment.NewLine))
|
||||
else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
lastText.Append(sb);
|
||||
TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
|
||||
@ -2346,11 +2346,11 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
private static string RemoveSubStationAlphaFormatting(string s)
|
||||
{
|
||||
int indexOfBegin = s.IndexOf("{", StringComparison.Ordinal);
|
||||
while (indexOfBegin >= 0 && s.IndexOf("}") > indexOfBegin)
|
||||
while (indexOfBegin >= 0 && s.IndexOf('}') > indexOfBegin)
|
||||
{
|
||||
int indexOfEnd = s.IndexOf("}");
|
||||
int indexOfEnd = s.IndexOf('}');
|
||||
s = s.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);
|
||||
indexOfBegin = s.IndexOf("{");
|
||||
indexOfBegin = s.IndexOf('{');
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -2758,8 +2758,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
//set language
|
||||
if (!string.IsNullOrEmpty(languageString))
|
||||
{
|
||||
if (languageString.Contains("(") && !languageString.StartsWith("("))
|
||||
languageString = languageString.Substring(0, languageString.IndexOf("(", StringComparison.Ordinal) - 1).Trim();
|
||||
if (languageString.Contains("(") && languageString[0] != '(')
|
||||
languageString = languageString.Substring(0, languageString.IndexOf('(') - 1).Trim();
|
||||
for (int i = 0; i < comboBoxLanguage.Items.Count; i++)
|
||||
{
|
||||
string l = comboBoxLanguage.Items[i].ToString();
|
||||
@ -3188,7 +3188,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOfEndBracket = _subtitle.Paragraphs[i].Text.IndexOf("}");
|
||||
int indexOfEndBracket = _subtitle.Paragraphs[i].Text.IndexOf('}');
|
||||
if (_subtitle.Paragraphs[i].Text.StartsWith("{\\") && indexOfEndBracket > 1 && indexOfEndBracket < 6)
|
||||
_subtitle.Paragraphs[i].Text = string.Format("{2}<{0}>{1}</{0}>", tag, _subtitle.Paragraphs[i].Text.Remove(0, indexOfEndBracket + 1), _subtitle.Paragraphs[i].Text.Substring(0, indexOfEndBracket + 1));
|
||||
else
|
||||
@ -3230,7 +3230,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
Paragraph p = _subtitle.GetParagraphOrDefault(item.Index);
|
||||
if (p != null)
|
||||
{
|
||||
int indexOfEndBracket = p.Text.IndexOf("}");
|
||||
int indexOfEndBracket = p.Text.IndexOf('}');
|
||||
if (p.Text.StartsWith("{\\") && indexOfEndBracket > 1 && indexOfEndBracket < 6)
|
||||
p.Text = p.Text.Remove(0, indexOfEndBracket + 1);
|
||||
p.Text = Utilities.RemoveHtmlTags(p.Text);
|
||||
@ -3248,12 +3248,12 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
|
||||
private static string RemoveSsaStyle(string text)
|
||||
{
|
||||
int indexOfBegin = text.IndexOf("{");
|
||||
while (indexOfBegin >= 0 && text.IndexOf("}") > indexOfBegin)
|
||||
int indexOfBegin = text.IndexOf('{');
|
||||
while (indexOfBegin >= 0 && text.IndexOf('}') > indexOfBegin)
|
||||
{
|
||||
int indexOfEnd = text.IndexOf("}");
|
||||
int indexOfEnd = text.IndexOf('}');
|
||||
text = text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);
|
||||
indexOfBegin = text.IndexOf("{");
|
||||
indexOfBegin = text.IndexOf('{');
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddFixToListView(p, fixAction1, text, p.Text);
|
||||
}
|
||||
}
|
||||
if (text.EndsWith(Environment.NewLine))
|
||||
if (text.EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
if (AllowFix(p, fixAction2))
|
||||
{
|
||||
@ -1274,7 +1274,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddFixToListView(p, fixAction, oldText, p.Text);
|
||||
}
|
||||
}
|
||||
if (p.Text.EndsWith("!."))
|
||||
if (p.Text.EndsWith("!.", StringComparison.Ordinal))
|
||||
{
|
||||
if (AllowFix(p, fixAction))
|
||||
{
|
||||
@ -1285,7 +1285,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddFixToListView(p, fixAction, oldText, p.Text);
|
||||
}
|
||||
}
|
||||
if (p.Text.EndsWith("?."))
|
||||
if (p.Text.EndsWith("?.", StringComparison.Ordinal))
|
||||
{
|
||||
if (AllowFix(p, fixAction))
|
||||
{
|
||||
@ -1538,8 +1538,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
!newText.Substring(1).StartsWith("♪") && !newText.Substring(1).StartsWith("♫"))
|
||||
newText = newText.Insert(1, " ");
|
||||
if ("#♪♫".Contains(newText[newText.Length - 1].ToString()) && !" >".Contains(newText[newText.Length - 2].ToString()) &&
|
||||
!newText.Substring(0, newText.Length - 1).EndsWith(Environment.NewLine) && !newText.Substring(0, newText.Length - 1).EndsWith("♪") &&
|
||||
!newText.Substring(0, newText.Length - 1).EndsWith("♫"))
|
||||
!newText.Substring(0, newText.Length - 1).EndsWith(Environment.NewLine, StringComparison.Ordinal) && !newText.Substring(0, newText.Length - 1).EndsWith("♪") &&
|
||||
!newText.Substring(0, newText.Length - 1).EndsWith("♫", StringComparison.Ordinal))
|
||||
newText = newText.Insert(newText.Length - 1, " ");
|
||||
if (newText != p.Text && AllowFix(p, fixAction))
|
||||
{
|
||||
@ -1716,7 +1716,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (betweenMilliseconds > 1500)
|
||||
next = null; // cannot be quote spanning several lines of more than 1.5 seconds between lines!
|
||||
else if (next.Text.Replace("<i>", string.Empty).TrimStart().TrimStart('-').TrimStart().StartsWith("\"") &&
|
||||
next.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith("\"") &&
|
||||
next.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith("\"", StringComparison.Ordinal) &&
|
||||
Utilities.CountTagInText(next.Text, "\"") == 2)
|
||||
next = null; // seems to have valid quotes, so no spanning
|
||||
}
|
||||
@ -1728,7 +1728,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (betweenMilliseconds > 1500)
|
||||
prev = null; // cannot be quote spanning several lines of more than 1.5 seconds between lines!
|
||||
else if (prev.Text.Replace("<i>", string.Empty).TrimStart().TrimStart('-').TrimStart().StartsWith("\"") &&
|
||||
prev.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith("\"") &&
|
||||
prev.Text.Replace("</i>", string.Empty).TrimEnd().EndsWith("\"", StringComparison.Ordinal) &&
|
||||
Utilities.CountTagInText(prev.Text, "\"") == 2)
|
||||
prev = null; // seems to have valid quotes, so no spanning
|
||||
}
|
||||
@ -1740,12 +1740,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
lines = p.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
string line = lines[0].Trim();
|
||||
|
||||
if (line.Length > 5 && line.TrimStart().StartsWith("- \"") && (line.EndsWith(".") || line.EndsWith("!") || line.EndsWith("?")))
|
||||
if (line.Length > 5 && line.TrimStart().StartsWith("- \"") && (line.EndsWith(".", StringComparison.Ordinal) || line.EndsWith("!", StringComparison.Ordinal) || line.EndsWith("?", StringComparison.Ordinal)))
|
||||
{
|
||||
p.Text = p.Text.Trim().Replace(" " + Environment.NewLine, Environment.NewLine);
|
||||
p.Text = p.Text.Replace(Environment.NewLine, "\"" + Environment.NewLine);
|
||||
}
|
||||
else if (line.Length > 5 && line.EndsWith("\"") && line.IndexOf("- ", StringComparison.Ordinal) >= 0 && line.IndexOf("- ", StringComparison.Ordinal) < 4)
|
||||
else if (line.Length > 5 && line.EndsWith("\"", StringComparison.Ordinal) && line.IndexOf("- ", StringComparison.Ordinal) >= 0 && line.IndexOf("- ", StringComparison.Ordinal) < 4)
|
||||
{
|
||||
p.Text = p.Text.Insert(line.IndexOf("- ", StringComparison.Ordinal) + 2, "\"");
|
||||
}
|
||||
@ -1766,11 +1766,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else if (lines[1].Contains("\""))
|
||||
{
|
||||
line = lines[1].Trim();
|
||||
if (line.Length > 5 && line.TrimStart().StartsWith("- \"") && (line.EndsWith(".") || line.EndsWith("!") || line.EndsWith("?")))
|
||||
if (line.Length > 5 && line.TrimStart().StartsWith("- \"") && (line.EndsWith(".", StringComparison.Ordinal) || line.EndsWith("!", StringComparison.Ordinal) || line.EndsWith("?", StringComparison.Ordinal)))
|
||||
{
|
||||
p.Text = p.Text.Trim() + "\"";
|
||||
}
|
||||
else if (line.Length > 5 && line.EndsWith("\"") && p.Text.IndexOf(Environment.NewLine + "- ", StringComparison.Ordinal) >= 0)
|
||||
else if (line.Length > 5 && line.EndsWith("\"", StringComparison.Ordinal) && p.Text.IndexOf(Environment.NewLine + "- ", StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
p.Text = p.Text.Insert(p.Text.IndexOf(Environment.NewLine + "- ", StringComparison.Ordinal) + Environment.NewLine.Length + 2, "\"");
|
||||
}
|
||||
@ -1796,12 +1796,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (next == null || !next.Text.Contains("\""))
|
||||
p.Text += "\"";
|
||||
}
|
||||
else if (p.Text.StartsWith("<i>\"") && p.Text.EndsWith("</i>") && Utilities.CountTagInText(p.Text, "</i>") == 1)
|
||||
else if (p.Text.StartsWith("<i>\"") && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "</i>") == 1)
|
||||
{
|
||||
if (next == null || !next.Text.Contains("\""))
|
||||
p.Text = p.Text.Replace("</i>", "\"</i>");
|
||||
}
|
||||
else if (p.Text.EndsWith("\""))
|
||||
else if (p.Text.EndsWith("\"", StringComparison.Ordinal))
|
||||
{
|
||||
if (prev == null || !prev.Text.Contains("\""))
|
||||
p.Text = "\"" + p.Text;
|
||||
@ -1816,13 +1816,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (next == null || !next.Text.Contains("\""))
|
||||
{
|
||||
if (p.Text.StartsWith("<i>") && p.Text.EndsWith("</i>") && Utilities.CountTagInText(p.Text, "</i>") == 1)
|
||||
if (p.Text.StartsWith("<i>") && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "</i>") == 1)
|
||||
p.Text = p.Text.Replace("</i>", "\"</i>");
|
||||
else
|
||||
p.Text = p.Text + "\"";
|
||||
}
|
||||
}
|
||||
else if (p.Text.StartsWith("<i>") && p.Text.EndsWith("</i>") && Utilities.CountTagInText(p.Text, "<i>") == 1)
|
||||
else if (p.Text.StartsWith("<i>") && p.Text.EndsWith("</i>", StringComparison.Ordinal) && Utilities.CountTagInText(p.Text, "<i>") == 1)
|
||||
{
|
||||
if (prev == null || !prev.Text.Contains("\""))
|
||||
p.Text = p.Text.Replace("<i>", "<i>\"");
|
||||
@ -1836,7 +1836,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int index = text.IndexOf('"');
|
||||
if (text[index - 1] == ' ')
|
||||
{
|
||||
if (p.Text.EndsWith(","))
|
||||
if (p.Text.EndsWith(",", StringComparison.Ordinal))
|
||||
p.Text = p.Text.Insert(p.Text.Length - 1, "\"").Trim();
|
||||
else
|
||||
p.Text = p.Text.Trim() + "\"";
|
||||
@ -2063,7 +2063,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string tempNoHtml = Utilities.RemoveHtmlTags(p.Text).TrimEnd();
|
||||
|
||||
|
||||
if (IsOneLineUrl(p.Text) || p.Text.Contains("♪") || p.Text.Contains("♫") || p.Text.EndsWith("'"))
|
||||
if (IsOneLineUrl(p.Text) || p.Text.Contains("♪") || p.Text.Contains("♫") || p.Text.EndsWith("'", StringComparison.Ordinal))
|
||||
{
|
||||
; // ignore urls
|
||||
}
|
||||
@ -2087,17 +2087,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (AllowFix(p, fixAction))
|
||||
{
|
||||
string oldText = p.Text;
|
||||
if (p.Text.EndsWith(">"))
|
||||
if (p.Text.EndsWith(">", StringComparison.Ordinal))
|
||||
{
|
||||
int lastLT = p.Text.LastIndexOf("<");
|
||||
int lastLT = p.Text.LastIndexOf('<');
|
||||
if (lastLT > 0)
|
||||
p.Text = p.Text.Insert(lastLT, ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.Text.EndsWith("“") && tempNoHtml.StartsWith("„"))
|
||||
if (p.Text.EndsWith("“", StringComparison.Ordinal) && tempNoHtml.StartsWith("„", StringComparison.Ordinal))
|
||||
p.Text = p.Text.TrimEnd('“') + ".“";
|
||||
else if (p.Text.EndsWith("\"") && tempNoHtml.StartsWith("\""))
|
||||
else if (p.Text.EndsWith("\"", StringComparison.Ordinal) && tempNoHtml.StartsWith("\"", StringComparison.Ordinal))
|
||||
p.Text = p.Text.TrimEnd('"') + ".\"";
|
||||
else
|
||||
p.Text += ".";
|
||||
@ -2162,9 +2162,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
string text = p.Text.Substring(0, indexOfNewLine);
|
||||
StripableText st = new StripableText(text);
|
||||
if (st.Pre.TrimEnd().EndsWith("¿")) // Spanish ¿
|
||||
if (st.Pre.TrimEnd().EndsWith("¿", StringComparison.Ordinal)) // Spanish ¿
|
||||
p.Text = p.Text.Insert(indexOfNewLine, "?");
|
||||
else if (st.Pre.TrimEnd().EndsWith("¡")) // Spanish ¡
|
||||
else if (st.Pre.TrimEnd().EndsWith("¡", StringComparison.Ordinal)) // Spanish ¡
|
||||
p.Text = p.Text.Insert(indexOfNewLine, "!");
|
||||
else
|
||||
p.Text = p.Text.Insert(indexOfNewLine, ".");
|
||||
@ -2331,9 +2331,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
isPrevEndOfLine)
|
||||
{
|
||||
bool isMatchInKnowAbbreviations = language == "en" &&
|
||||
(prevText.EndsWith(" o.r.") ||
|
||||
prevText.EndsWith(" a.m.") ||
|
||||
prevText.EndsWith(" p.m."));
|
||||
(prevText.EndsWith(" o.r.", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith(" a.m.", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith(" p.m.", StringComparison.Ordinal));
|
||||
|
||||
if (!isMatchInKnowAbbreviations)
|
||||
{
|
||||
@ -2403,13 +2403,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bool isPrevEndOfLine = IsPrevoiusTextEndOfParagraph(prevText);
|
||||
if ((!text.StartsWith("www.") && !text.StartsWith("http:") && !text.StartsWith("https:")) &&
|
||||
(firstLetter != firstLetter.ToUpper() || IsTurkishLittleI(firstLetter, encoding, language)) &&
|
||||
!prevText.EndsWith("...") &&
|
||||
!prevText.EndsWith("...", StringComparison.Ordinal) &&
|
||||
isPrevEndOfLine)
|
||||
{
|
||||
bool isMatchInKnowAbbreviations = language == "en" &&
|
||||
(prevText.EndsWith(" o.r.") ||
|
||||
prevText.EndsWith(" a.m.") ||
|
||||
prevText.EndsWith(" p.m."));
|
||||
(prevText.EndsWith(" o.r.", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith(" a.m.", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith(" p.m.", StringComparison.Ordinal));
|
||||
|
||||
if (!isMatchInKnowAbbreviations)
|
||||
{
|
||||
@ -2506,12 +2506,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string text = p.Text.Substring(indexOfNewLine + len);
|
||||
StripableText st = new StripableText(text);
|
||||
|
||||
if (st.StrippedText.Length > 0 && IsTurkishLittleI(st.StrippedText, encoding, language) && !st.Pre.EndsWith("[") && !st.Pre.Contains("..."))
|
||||
if (st.StrippedText.Length > 0 && IsTurkishLittleI(st.StrippedText, encoding, language) && !st.Pre.EndsWith("[", StringComparison.Ordinal) && !st.Pre.Contains("..."))
|
||||
{
|
||||
text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, GetTurkishUppercaseLetter(st.StrippedText, encoding)) + st.Post;
|
||||
p.Text = p.Text.Remove(indexOfNewLine + len).Insert(indexOfNewLine + len, text);
|
||||
}
|
||||
else if (st.StrippedText.Length > 0 && st.StrippedText[0] != char.ToUpper(st.StrippedText[0]) && !st.Pre.EndsWith("[") && !st.Pre.Contains("..."))
|
||||
else if (st.StrippedText.Length > 0 && st.StrippedText[0] != char.ToUpper(st.StrippedText[0]) && !st.Pre.EndsWith("[", StringComparison.Ordinal) && !st.Pre.Contains("..."))
|
||||
{
|
||||
text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, st.StrippedText[0].ToString().ToUpper()) + st.Post;
|
||||
p.Text = p.Text.Remove(indexOfNewLine + len).Insert(indexOfNewLine + len, text);
|
||||
@ -2555,12 +2555,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
prevText = prevText.Replace("♪", string.Empty).Replace("♫", string.Empty).Trim();
|
||||
bool isPrevEndOfLine = prevText.Length > 1 &&
|
||||
!prevText.EndsWith("...") &&
|
||||
(prevText.EndsWith(".") ||
|
||||
prevText.EndsWith("!") ||
|
||||
prevText.EndsWith("?"));
|
||||
!prevText.EndsWith("...", StringComparison.Ordinal) &&
|
||||
(prevText.EndsWith(".", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith("!", StringComparison.Ordinal) ||
|
||||
prevText.EndsWith("?", StringComparison.Ordinal));
|
||||
|
||||
if (isPrevEndOfLine && prevText.Length > 5 && prevText.EndsWith(".") &&
|
||||
if (isPrevEndOfLine && prevText.Length > 5 && prevText.EndsWith(".", StringComparison.Ordinal) &&
|
||||
prevText[prevText.Length - 3] == '.' &&
|
||||
Utilities.AllLetters.Contains(prevText[prevText.Length - 2].ToString()))
|
||||
isPrevEndOfLine = false;
|
||||
@ -2647,7 +2647,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (last != null)
|
||||
{
|
||||
string lastText = Utilities.RemoveHtmlTags(last.Text);
|
||||
if (lastText.EndsWith(":") || lastText.EndsWith(";"))
|
||||
if (lastText.EndsWith(":", StringComparison.Ordinal) || lastText.EndsWith(";", StringComparison.Ordinal))
|
||||
{
|
||||
var st = new StripableText(p.Text);
|
||||
if (st.StrippedText.Length > 0 && st.StrippedText[0] != char.ToUpper(st.StrippedText[0]))
|
||||
@ -2964,7 +2964,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (match.Index > 1)
|
||||
wholePrev = s.Substring(0, match.Index - 1);
|
||||
|
||||
if (prev != ">" && next != ">" && next != "}" && !wholePrev.Trim().EndsWith("..."))
|
||||
if (prev != ">" && next != ">" && next != "}" && !wholePrev.Trim().EndsWith("...", StringComparison.Ordinal))
|
||||
{
|
||||
bool fix = true;
|
||||
|
||||
@ -3018,7 +3018,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
Paragraph prev = _subtitle.GetParagraphOrDefault(i - 1);
|
||||
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-"))
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-", StringComparison.Ordinal))
|
||||
{
|
||||
var lines = Utilities.RemoveHtmlTags(p.Text).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
int startHyphenCount = 0;
|
||||
@ -3105,11 +3105,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else if (text.StartsWith("<font "))
|
||||
{
|
||||
Paragraph prev = _subtitle.GetParagraphOrDefault(i - 1);
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-"))
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-", StringComparison.Ordinal))
|
||||
{
|
||||
string oldText = p.Text;
|
||||
var st = new StripableText(text);
|
||||
if (st.Pre.EndsWith("-") || st.Pre.EndsWith("- "))
|
||||
if (st.Pre.EndsWith("-", StringComparison.Ordinal) || st.Pre.EndsWith("- ", StringComparison.Ordinal))
|
||||
{
|
||||
text = st.Pre.TrimEnd().TrimEnd('-').TrimEnd() + st.StrippedText + st.Post;
|
||||
}
|
||||
@ -3153,7 +3153,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
Paragraph prev = _subtitle.GetParagraphOrDefault(i - 1);
|
||||
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-"))
|
||||
if (prev == null || !Utilities.RemoveHtmlTags(prev.Text).Trim().EndsWith("-", StringComparison.Ordinal))
|
||||
{
|
||||
var lines = Utilities.RemoveHtmlTags(p.Text).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
int startHyphenCount = 0;
|
||||
@ -3169,11 +3169,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string[] parts = Utilities.RemoveHtmlTags(text).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
bool doAdd = parts[0].Trim().EndsWith(".") || parts[0].Trim().EndsWith("!") || parts[0].Trim().EndsWith("?") || Language == "ko";
|
||||
bool doAdd = parts[0].Trim().EndsWith(".", StringComparison.Ordinal) || parts[0].Trim().EndsWith("!", StringComparison.Ordinal) || parts[0].Trim().EndsWith("?", StringComparison.Ordinal) || Language == "ko";
|
||||
|
||||
if (parts[0].Trim().StartsWith("-") && parts[1].Contains(":"))
|
||||
if (parts[0].Trim().StartsWith("-", StringComparison.Ordinal) && parts[1].Contains(":"))
|
||||
doAdd = false;
|
||||
if (parts[1].Trim().StartsWith("-") && parts[0].Contains(":"))
|
||||
if (parts[1].Trim().StartsWith("-", StringComparison.Ordinal) && parts[0].Contains(":"))
|
||||
doAdd = false;
|
||||
|
||||
if (doAdd)
|
||||
@ -3332,7 +3332,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
text = text.Remove(0, 1);
|
||||
text = text.Insert(0, "...");
|
||||
}
|
||||
if (p.Text.EndsWith("—"))
|
||||
if (p.Text.EndsWith("—", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Substring(0, text.Length - 1) + "...";
|
||||
text = text.Replace(" ...", "...");
|
||||
@ -4214,10 +4214,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Paragraph p = _subtitle.Paragraphs[i];
|
||||
Paragraph last = _subtitle.GetParagraphOrDefault(i - 1);
|
||||
|
||||
bool wasLastLineClosed = last == null || last.Text.EndsWith("?") || last.Text.EndsWith("!") || last.Text.EndsWith(".") ||
|
||||
last.Text.EndsWith(":") || last.Text.EndsWith(")") || last.Text.EndsWith("]");
|
||||
bool wasLastLineClosed = last == null || last.Text.EndsWith("?", StringComparison.Ordinal) || last.Text.EndsWith("!", StringComparison.Ordinal) || last.Text.EndsWith(".", StringComparison.Ordinal) ||
|
||||
last.Text.EndsWith(":", StringComparison.Ordinal) || last.Text.EndsWith(")", StringComparison.Ordinal) || last.Text.EndsWith("]", StringComparison.Ordinal);
|
||||
string trimmedStart = p.Text.TrimStart(("- ").ToCharArray());
|
||||
if (last != null && last.Text.EndsWith("...") && trimmedStart.Length > 0 && trimmedStart[0].ToString() == trimmedStart[0].ToString().ToLower())
|
||||
if (last != null && last.Text.EndsWith("...", StringComparison.Ordinal) && trimmedStart.Length > 0 && trimmedStart[0].ToString() == trimmedStart[0].ToString().ToLower())
|
||||
wasLastLineClosed = false;
|
||||
if (!wasLastLineClosed && last != null && last.Text == last.Text.ToUpper())
|
||||
wasLastLineClosed = true;
|
||||
@ -4319,11 +4319,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var st = new StripableText(part);
|
||||
if (j == 0 && mark == "!" && st.Pre == "¿" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark))
|
||||
if (j == 0 && mark == "!" && st.Pre == "¿" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark, StringComparison.Ordinal))
|
||||
{
|
||||
p.Text = inverseMark + p.Text;
|
||||
}
|
||||
else if (j == 0 && mark == "?" && st.Pre == "¡" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark))
|
||||
else if (j == 0 && mark == "?" && st.Pre == "¡" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark, StringComparison.Ordinal))
|
||||
{
|
||||
p.Text = inverseMark + p.Text;
|
||||
}
|
||||
@ -4368,7 +4368,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
wasLastLineClosed = true;
|
||||
}
|
||||
}
|
||||
if (p.Text.EndsWith(mark + "...") && p.Text.Length > 4)
|
||||
if (p.Text.EndsWith(mark + "...", StringComparison.Ordinal) && p.Text.Length > 4)
|
||||
{
|
||||
p.Text = p.Text.Remove(p.Text.Length - 4, 4) + "..." + mark;
|
||||
}
|
||||
@ -5377,7 +5377,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
string oldText = currentParagraph.Text;
|
||||
string[] lines = currentParagraph.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines.Length == 2 && (lines[0].EndsWith(".") || lines[0].EndsWith("!") || lines[0].EndsWith("?")))
|
||||
if (lines.Length == 2 && (lines[0].EndsWith(".", StringComparison.Ordinal) || lines[0].EndsWith("!", StringComparison.Ordinal) || lines[0].EndsWith("?", StringComparison.Ordinal)))
|
||||
{
|
||||
currentParagraph.Text = Utilities.AutoBreakLine(lines[0], Language);
|
||||
newParagraph.Text = Utilities.AutoBreakLine(lines[1], Language);
|
||||
|
@ -188,7 +188,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
foreach (ZipExtractor.ZipFileEntry entry in dir)
|
||||
{
|
||||
if (entry.FilenameInZip.ToLower().EndsWith(".zip"))
|
||||
if (entry.FilenameInZip.ToLower().EndsWith(".zip", StringComparison.Ordinal))
|
||||
{
|
||||
var innerMs = new MemoryStream();
|
||||
zip.ExtractFile(entry, innerMs);
|
||||
|
@ -446,7 +446,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
res = res.Replace(Environment.NewLine + " ", Environment.NewLine).Trim();
|
||||
res = res.Replace(" " + Environment.NewLine, Environment.NewLine).Trim();
|
||||
res = res.Replace(" " + Environment.NewLine, Environment.NewLine).Trim();
|
||||
int end = res.LastIndexOf("<p>");
|
||||
int end = res.LastIndexOf("<p>", StringComparison.Ordinal);
|
||||
if (end > 0)
|
||||
res = res.Substring(0, end);
|
||||
return res;
|
||||
|
@ -380,11 +380,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (pos + 35 < textBoxSource.TextLength)
|
||||
pos += 35;
|
||||
string s = textBoxSource.Text.Substring(0, pos);
|
||||
int lastTimeCode = s.LastIndexOf(" --> "); // 00:02:26,407 --> 00:02:31,356
|
||||
int lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); // 00:02:26,407 --> 00:02:31,356
|
||||
if (lastTimeCode > 14 && lastTimeCode + 16 >= s.Length)
|
||||
{
|
||||
s = s.Substring(0, lastTimeCode - 5);
|
||||
lastTimeCode = s.LastIndexOf(" --> ");
|
||||
lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
if (lastTimeCode > 14 && lastTimeCode + 16 < s.Length)
|
||||
@ -710,7 +710,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOfDirectorySeparatorChar = pattern.LastIndexOf(Path.DirectorySeparatorChar.ToString());
|
||||
int indexOfDirectorySeparatorChar = pattern.LastIndexOf(Path.DirectorySeparatorChar);
|
||||
if (indexOfDirectorySeparatorChar > 0 && indexOfDirectorySeparatorChar < pattern.Length)
|
||||
{
|
||||
pattern = pattern.Substring(indexOfDirectorySeparatorChar + 1);
|
||||
@ -2622,7 +2622,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (fileName.ToLower().EndsWith(".dost"))
|
||||
if (fileName.ToLower().EndsWith(".dost", StringComparison.Ordinal))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2674,7 +2674,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
foreach (Paragraph p in _subtitle.Paragraphs)
|
||||
{
|
||||
string s = p.Text.ToLower();
|
||||
if (s.EndsWith(".bmp") || s.EndsWith(".png") || s.EndsWith(".jpg") || s.EndsWith(".tif"))
|
||||
if (s.EndsWith(".bmp", StringComparison.Ordinal) || s.EndsWith(".png", StringComparison.Ordinal) || s.EndsWith(".jpg", StringComparison.Ordinal) || s.EndsWith(".tif", StringComparison.Ordinal))
|
||||
{
|
||||
imageCount++;
|
||||
}
|
||||
@ -2830,7 +2830,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string s = File.ReadAllText(fileName, enc);
|
||||
|
||||
// check for RTF file
|
||||
if (fileName.ToLower().EndsWith(".rtf") && !s.Trim().StartsWith("{\\rtf"))
|
||||
if (fileName.ToLower().EndsWith(".rtf", StringComparison.Ordinal) && !s.Trim().StartsWith("{\\rtf", StringComparison.Ordinal))
|
||||
{
|
||||
var rtBox = new RichTextBox();
|
||||
rtBox.Rtf = s;
|
||||
@ -3033,7 +3033,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileName) && fileName.ToLower().EndsWith(".xml"))
|
||||
if (!string.IsNullOrEmpty(fileName) && fileName.ToLower().EndsWith(".xml", StringComparison.Ordinal))
|
||||
{
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
var sb = new StringBuilder();
|
||||
@ -3478,7 +3478,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bool extOk = ext == format.Extension.ToLower() || format.AlternateExtensions.Contains(ext) || ext == ".txt";
|
||||
if (!extOk)
|
||||
{
|
||||
if (_fileName.EndsWith("."))
|
||||
if (_fileName.EndsWith(".", StringComparison.Ordinal))
|
||||
_fileName = _fileName.Substring(0, _fileName.Length - 1);
|
||||
_fileName += format.Extension;
|
||||
}
|
||||
@ -7272,12 +7272,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
// If the first subtitle ends with a tag (</i>):
|
||||
String endTag = "";
|
||||
if (p.Text.EndsWith(">") && p.Text.Contains("<"))
|
||||
if (p.Text.EndsWith(">", StringComparison.Ordinal) && p.Text.Contains("<"))
|
||||
{
|
||||
// Save the end tag.
|
||||
endTag = p.Text.Substring(p.Text.LastIndexOf("<"), p.Text.Length - p.Text.LastIndexOf("<"));
|
||||
endTag = p.Text.Substring(p.Text.LastIndexOf('<'), p.Text.Length - p.Text.LastIndexOf('<'));
|
||||
// Remove the endTag from first subtitle.
|
||||
p.Text = p.Text.Remove(p.Text.LastIndexOf("<"));
|
||||
p.Text = p.Text.Remove(p.Text.LastIndexOf('<'));
|
||||
}
|
||||
|
||||
// If the first subtitle ends with "...":
|
||||
@ -7365,7 +7365,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (p != null && next != null)
|
||||
{
|
||||
string s = p.Text.Trim();
|
||||
int idx = s.LastIndexOf(" ");
|
||||
int idx = s.LastIndexOf(' ');
|
||||
if (idx > 0 || s.Length > 0)
|
||||
// A last word was found or the first subtitle is not empty (has one word).
|
||||
{
|
||||
@ -7392,9 +7392,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (lastWord.EndsWith(">") && lastWord.Contains("<"))
|
||||
{
|
||||
// Save the end tag.
|
||||
endTag = lastWord.Substring(lastWord.LastIndexOf("<"), lastWord.Length - lastWord.LastIndexOf("<"));
|
||||
endTag = lastWord.Substring(lastWord.LastIndexOf('<'), lastWord.Length - lastWord.LastIndexOf("<"));
|
||||
// Remove the end tag from the last word.
|
||||
lastWord = lastWord.Remove(lastWord.LastIndexOf("<"));
|
||||
lastWord = lastWord.Remove(lastWord.LastIndexOf('<'));
|
||||
}
|
||||
|
||||
// If the first subtitle ends with "...":
|
||||
@ -8691,7 +8691,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int start = textBoxSource.Text.IndexOf(tc);
|
||||
if (start > 0)
|
||||
{
|
||||
int start2 = textBoxSource.Text.LastIndexOf("Dialogue:", start);
|
||||
int start2 = textBoxSource.Text.LastIndexOf("Dialogue:", start, StringComparison.Ordinal);
|
||||
if (start2 > 0)
|
||||
start2 = (textBoxSource.Text + Environment.NewLine).IndexOf(Environment.NewLine, start2);
|
||||
if (start2 > 0)
|
||||
@ -8720,11 +8720,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (pos + 35 < textBoxSource.TextLength)
|
||||
pos += 35;
|
||||
string s = textBoxSource.Text.Substring(0, pos);
|
||||
int lastTimeCode = s.LastIndexOf(" --> "); // 00:02:26,407 --> 00:02:31,356
|
||||
int lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); // 00:02:26,407 --> 00:02:31,356
|
||||
if (lastTimeCode > 14 && lastTimeCode + 16 >= s.Length)
|
||||
{
|
||||
s = s.Substring(0, lastTimeCode - 5);
|
||||
lastTimeCode = s.LastIndexOf(" --> ");
|
||||
lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
if (lastTimeCode > 14 && lastTimeCode + 16 < s.Length)
|
||||
@ -13302,7 +13302,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (fileNameNoExtension.Contains("."))
|
||||
{
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf("."));
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.'));
|
||||
TryToFindAndOpenVideoFile(fileNameNoExtension);
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return string.Empty;
|
||||
|
||||
string endTag = string.Empty;
|
||||
int start = text.LastIndexOf("</");
|
||||
int start = text.LastIndexOf("</", StringComparison.Ordinal);
|
||||
if (start > 0 && start >= text.Length - 8)
|
||||
{
|
||||
endTag = text.Substring(start);
|
||||
|
@ -93,7 +93,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (fileNameNoExtension.Contains("."))
|
||||
{
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf("."));
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.'));
|
||||
TryToFindAndOpenVideoFile(fileNameNoExtension);
|
||||
}
|
||||
}
|
||||
|
@ -1032,8 +1032,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
{
|
||||
string name = Utilities.GetDictionaryLanguages()[0];
|
||||
int start = name.LastIndexOf("[");
|
||||
int end = name.LastIndexOf("]");
|
||||
int start = name.LastIndexOf('[');
|
||||
int end = name.LastIndexOf(']');
|
||||
if (start > 0 && end > start)
|
||||
{
|
||||
start++;
|
||||
|
@ -379,7 +379,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (fileNameNoExtension.Contains("."))
|
||||
{
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf("."));
|
||||
fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.'));
|
||||
TryToFindAndOpenMovieFile(fileNameNoExtension);
|
||||
}
|
||||
}
|
||||
|
@ -7296,8 +7296,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return null;
|
||||
|
||||
string name = comboBoxDictionaries.SelectedItem.ToString();
|
||||
int start = name.LastIndexOf("[");
|
||||
int end = name.LastIndexOf("]");
|
||||
int start = name.LastIndexOf('[');
|
||||
int end = name.LastIndexOf(']');
|
||||
if (start >= 0 && end > start)
|
||||
{
|
||||
start++;
|
||||
|
@ -422,11 +422,11 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
||||
{
|
||||
StripableText temp = new StripableText(text);
|
||||
temp.StrippedText = temp.StrippedText.Replace(Environment.NewLine, " ");
|
||||
int splitIndex = temp.StrippedText.LastIndexOf("!", StringComparison.Ordinal);
|
||||
int splitIndex = temp.StrippedText.LastIndexOf('!');
|
||||
if (splitIndex == -1)
|
||||
splitIndex = temp.StrippedText.LastIndexOf("?", StringComparison.Ordinal);
|
||||
splitIndex = temp.StrippedText.LastIndexOf('?');
|
||||
if (splitIndex == -1)
|
||||
splitIndex = temp.StrippedText.LastIndexOf(".", StringComparison.Ordinal);
|
||||
splitIndex = temp.StrippedText.LastIndexOf('.');
|
||||
if (splitIndex > 0)
|
||||
{
|
||||
text = temp.Pre + temp.StrippedText.Insert(splitIndex + 1, Environment.NewLine) + temp.Post;
|
||||
|
@ -955,7 +955,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
if (HexNumber.IsMatch(word))
|
||||
return word;
|
||||
|
||||
if (word.LastIndexOf("0", StringComparison.Ordinal) > 0)
|
||||
if (word.LastIndexOf('0') > 0)
|
||||
{
|
||||
Match match = RegExTime1.Match(word);
|
||||
if (match.Success)
|
||||
|
@ -75,21 +75,21 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
text = text.Substring(0, text.Length - 1);
|
||||
}
|
||||
|
||||
if (text.EndsWith(">"))
|
||||
if (text.EndsWith(">", StringComparison.Ordinal))
|
||||
{
|
||||
string lower = text.ToLower();
|
||||
|
||||
// tags </i> </b> </u>
|
||||
if (lower.EndsWith("</i>") ||
|
||||
lower.EndsWith("</b>") ||
|
||||
lower.EndsWith("</u>"))
|
||||
if (lower.EndsWith("</i>", StringComparison.Ordinal) ||
|
||||
lower.EndsWith("</b>", StringComparison.Ordinal) ||
|
||||
lower.EndsWith("</u>", StringComparison.Ordinal))
|
||||
{
|
||||
Post = text.Substring(text.Length - 4, 4) + Post;
|
||||
text = text.Substring(0, text.Length - 4);
|
||||
}
|
||||
|
||||
// tag </font>
|
||||
if (lower.EndsWith("</font>"))
|
||||
if (lower.EndsWith("</font>", StringComparison.Ordinal))
|
||||
{
|
||||
Post = text.Substring(text.Length - 7, 7) + Post;
|
||||
text = text.Substring(0, text.Length - 7);
|
||||
@ -132,7 +132,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
bool startOk = (start == 0) || (lower[start - 1] == ' ') || (lower[start - 1] == '-') ||
|
||||
(lower[start - 1] == '"') || (lower[start - 1] == '\'') || (lower[start - 1] == '>') ||
|
||||
(Environment.NewLine.EndsWith(lower[start - 1].ToString()));
|
||||
(Environment.NewLine.EndsWith(lower[start - 1].ToString(), StringComparison.Ordinal));
|
||||
|
||||
if (startOk)
|
||||
{
|
||||
@ -157,7 +157,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
|
||||
if (StrippedText.EndsWith("."))
|
||||
if (StrippedText.EndsWith(".", StringComparison.Ordinal))
|
||||
{
|
||||
Post = "." + Post;
|
||||
StrippedText = StrippedText.TrimEnd('.');
|
||||
@ -185,18 +185,18 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
|
||||
bool startWithUppercase = string.IsNullOrEmpty(s) ||
|
||||
s.EndsWith(".") ||
|
||||
s.EndsWith("!") ||
|
||||
s.EndsWith("?") ||
|
||||
s.EndsWith(". ♪") ||
|
||||
s.EndsWith("! ♪") ||
|
||||
s.EndsWith("? ♪") ||
|
||||
s.EndsWith("]") ||
|
||||
s.EndsWith(")") ||
|
||||
s.EndsWith(":");
|
||||
s.EndsWith(".", StringComparison.Ordinal) ||
|
||||
s.EndsWith("!", StringComparison.Ordinal) ||
|
||||
s.EndsWith("?", StringComparison.Ordinal) ||
|
||||
s.EndsWith(". ♪", StringComparison.Ordinal) ||
|
||||
s.EndsWith("! ♪", StringComparison.Ordinal) ||
|
||||
s.EndsWith("? ♪", StringComparison.Ordinal) ||
|
||||
s.EndsWith("]", StringComparison.Ordinal) ||
|
||||
s.EndsWith(")", StringComparison.Ordinal) ||
|
||||
s.EndsWith(":", StringComparison.Ordinal);
|
||||
|
||||
// start with uppercase after music symbol - but only if next line not starts with music symbol
|
||||
if (!startWithUppercase && (s.EndsWith("♪") || s.EndsWith("♫")))
|
||||
if (!startWithUppercase && (s.EndsWith("♪", StringComparison.Ordinal) || s.EndsWith("♫", StringComparison.Ordinal)))
|
||||
{
|
||||
if (!Pre.Contains("♪") && !Pre.Contains("♫"))
|
||||
startWithUppercase = true;
|
||||
@ -232,15 +232,15 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
sb.Append(s);
|
||||
}
|
||||
else if ((sb.ToString().EndsWith("<") || sb.ToString().EndsWith("</")) && i + 1 < StrippedText.Length && StrippedText[i + 1] == '>')
|
||||
else if ((sb.ToString().EndsWith("<", StringComparison.Ordinal) || sb.ToString().EndsWith("</", StringComparison.Ordinal)) && i + 1 < StrippedText.Length && StrippedText[i + 1] == '>')
|
||||
{ // tags
|
||||
sb.Append(s);
|
||||
}
|
||||
else if (sb.ToString().EndsWith("<") && s == "/" && i + 2 < StrippedText.Length && StrippedText[i + 2] == '>')
|
||||
else if (sb.ToString().EndsWith("<", StringComparison.Ordinal) && s == "/" && i + 2 < StrippedText.Length && StrippedText[i + 2] == '>')
|
||||
{ // tags
|
||||
sb.Append(s);
|
||||
}
|
||||
else if (sb.ToString().EndsWith("... "))
|
||||
else if (sb.ToString().EndsWith("... ", StringComparison.Ordinal))
|
||||
{
|
||||
sb.Append(s);
|
||||
lastWasBreak = false;
|
||||
|
@ -67,7 +67,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
var sb = new StringBuilder();
|
||||
lines.ForEach(line => sb.AppendLine(line));
|
||||
string all = sb.ToString();
|
||||
if (!string.IsNullOrEmpty(fileName) && fileName.ToLower().EndsWith(".ass") && !all.Contains("[V4 Styles]"))
|
||||
if (!string.IsNullOrEmpty(fileName) && fileName.ToLower().EndsWith(".ass", StringComparison.Ordinal) && !all.Contains("[V4 Styles]"))
|
||||
{
|
||||
}
|
||||
else if (!all.ToLower().Contains("dialogue:"))
|
||||
|
@ -120,7 +120,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
try
|
||||
{
|
||||
|
||||
int textIndex = s.LastIndexOf("]") + 1;
|
||||
int textIndex = s.LastIndexOf(']') + 1;
|
||||
if (textIndex < s.Length)
|
||||
{
|
||||
string text = s.Substring(textIndex);
|
||||
|
@ -85,7 +85,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
string[] endParts = end.Split(":.\"".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
string text = line.Substring(line.LastIndexOf("/>") + 2);
|
||||
string text = line.Substring(line.LastIndexOf("/>", StringComparison.Ordinal) + 2);
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
string[] endParts = end.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
int lastIndexOfTab = line.LastIndexOf("\t");
|
||||
int lastIndexOfTab = line.LastIndexOf('\t');
|
||||
string text = line.Remove(0, lastIndexOfTab+1).Trim();
|
||||
if (!text.Contains(Environment.NewLine))
|
||||
text = text.Replace("\t", Environment.NewLine);
|
||||
|
@ -235,9 +235,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
// Fix a few more cases of wrong time codes, seen this: 00.00.02,000 --> 00.00.04,000
|
||||
line = line.Replace('.', ':');
|
||||
if (line.Length >= 29 && ":;".Contains(line[8].ToString()))
|
||||
if (line.Length >= 29 && (line[8] == ':' || line[8] == ';'))
|
||||
line = line.Substring(0, 8) + ',' + line.Substring(8 + 1);
|
||||
if (line.Length >= 29 && line.Length <= 30 && ":;".Contains(line[25].ToString()))
|
||||
if (line.Length >= 29 && line.Length <= 30 && (line[25] == ':' || line[25] == ';'))
|
||||
line = line.Substring(0, 25) + ',' + line.Substring(25 + 1);
|
||||
|
||||
if (_regexTimeCodes.IsMatch(line) || _regexTimeCodes2.IsMatch(line))
|
||||
|
@ -378,7 +378,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
|
||||
if (s2.EndsWith("? -") || s2.EndsWith("! -") || s2.EndsWith(". -"))
|
||||
if (s2.EndsWith("? -", StringComparison.Ordinal) || s2.EndsWith("! -", StringComparison.Ordinal) || s2.EndsWith(". -", StringComparison.Ordinal))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -553,7 +553,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (arr.Length == 2)
|
||||
{
|
||||
string arr0 = arr[0].Trim().TrimEnd('"').TrimEnd('\'').TrimEnd();
|
||||
if (arr0.StartsWith("-") && arr[1].Trim().StartsWith("-") && (arr0.EndsWith(".") || arr0.EndsWith("!") || arr0.EndsWith("?")))
|
||||
if (arr0.StartsWith("-", StringComparison.Ordinal) && arr[1].Trim().StartsWith("-", StringComparison.Ordinal) && (arr0.EndsWith(".", StringComparison.Ordinal) || arr0.EndsWith("!", StringComparison.Ordinal) || arr0.EndsWith("?", StringComparison.Ordinal)))
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@ -963,7 +963,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{ // keep utf-8 encoding if it's default
|
||||
encoding = Encoding.UTF8;
|
||||
}
|
||||
else if (couldBeUtf8 && fileName.ToLower().EndsWith(".xml") && Encoding.Default.GetString(buffer).ToLower().Replace("'", "\"").Contains("encoding=\"utf-8\""))
|
||||
else if (couldBeUtf8 && fileName.ToLower().EndsWith(".xml", StringComparison.Ordinal) && Encoding.Default.GetString(buffer).ToLower().Replace("'", "\"").Contains("encoding=\"utf-8\""))
|
||||
{ // keep utf-8 encoding for xml files with utf-8 in header (without any utf-8 encoded characters, but with only allowed utf-8 characters)
|
||||
encoding = Encoding.UTF8;
|
||||
}
|
||||
@ -2299,7 +2299,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (s.IndexOf(word, StringComparison.Ordinal) >= 0 && text.IndexOf(s, StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
if (s.StartsWith(word + " ") || s.EndsWith(" " + word) || s.Contains(" " + word + " "))
|
||||
if (s.StartsWith(word + " ", StringComparison.Ordinal) || s.EndsWith(" " + word, StringComparison.Ordinal) || s.Contains(" " + word + " "))
|
||||
return true;
|
||||
if (word == s)
|
||||
return true;
|
||||
@ -2317,7 +2317,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (s.Contains(word) && text.Contains(s))
|
||||
{
|
||||
if (s.StartsWith(word + " ") || s.EndsWith(" " + word) || s.Contains(" " + word + " "))
|
||||
if (s.StartsWith(word + " ", StringComparison.Ordinal) || s.EndsWith(" " + word, StringComparison.Ordinal) || s.Contains(" " + word + " "))
|
||||
return true;
|
||||
if (word == s)
|
||||
return true;
|
||||
@ -2576,8 +2576,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (italicBeginTagCount == 2 && italicEndTagCount == 1)
|
||||
{
|
||||
var lines = text.Replace(Environment.NewLine, "\n").Split('\n');
|
||||
if (lines.Length == 2 && lines[0].StartsWith("<i>") && lines[0].EndsWith("</i>") &&
|
||||
lines[1].StartsWith("<i>"))
|
||||
if (lines.Length == 2 && lines[0].StartsWith("<i>") && lines[0].EndsWith("</i>", StringComparison.Ordinal) &&
|
||||
lines[1].StartsWith("<i>", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.TrimEnd() + "</i>";
|
||||
}
|
||||
@ -2589,7 +2589,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
else
|
||||
text = text.Substring(0, lastIndex - 1) + endTag;
|
||||
}
|
||||
if (text.StartsWith("<i>") && text.EndsWith("</i>") && text.Contains("</i>" + Environment.NewLine + "<i>"))
|
||||
if (text.StartsWith("<i>", StringComparison.Ordinal) && text.EndsWith("</i>", StringComparison.Ordinal) && text.Contains("</i>" + Environment.NewLine + "<i>"))
|
||||
{
|
||||
text = text.Replace("</i>" + Environment.NewLine + "<i>", Environment.NewLine);
|
||||
}
|
||||
@ -2614,7 +2614,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
bool isFixed= false;
|
||||
|
||||
// Foo.</i>
|
||||
if (text.EndsWith(endTag) && !cleanText.StartsWith("-") && !cleanText.Contains(Environment.NewLine + "-"))
|
||||
if (text.EndsWith(endTag, StringComparison.Ordinal) && !cleanText.StartsWith("-", StringComparison.Ordinal) && !cleanText.Contains(Environment.NewLine + "-"))
|
||||
{
|
||||
text = beginTag + text;
|
||||
isFixed = true;
|
||||
@ -2629,12 +2629,12 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
var firstLine = text.Substring(0, newLineIndex).Trim();
|
||||
var secondLine = text.Substring(newLineIndex + 2).Trim();
|
||||
if (firstLine.EndsWith(endTag))
|
||||
if (firstLine.EndsWith(endTag, StringComparison.Ordinal))
|
||||
{
|
||||
firstLine = beginTag + firstLine;
|
||||
isFixed = true;
|
||||
}
|
||||
if (secondLine.EndsWith(endTag))
|
||||
if (secondLine.EndsWith(endTag, StringComparison.Ordinal))
|
||||
{
|
||||
secondLine = beginTag + secondLine;
|
||||
isFixed = true;
|
||||
@ -2648,13 +2648,13 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
// - foo.</i>
|
||||
// - bar.</i>
|
||||
if (italicBeginTagCount == 0 && italicEndTagCount == 2 && text.Contains(endTag + Environment.NewLine) && text.EndsWith(endTag))
|
||||
if (italicBeginTagCount == 0 && italicEndTagCount == 2 && text.Contains(endTag + Environment.NewLine) && text.EndsWith(endTag, StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Replace(endTag, string.Empty);
|
||||
text = beginTag + text + endTag;
|
||||
}
|
||||
|
||||
if (italicBeginTagCount == 0 && italicEndTagCount == 2 && text.StartsWith("</i>") && text.EndsWith("</i>"))
|
||||
if (italicBeginTagCount == 0 && italicEndTagCount == 2 && text.StartsWith("</i>", StringComparison.Ordinal) && text.EndsWith("</i>", StringComparison.Ordinal))
|
||||
{
|
||||
int firstIndex = text.IndexOf(endTag, StringComparison.Ordinal);
|
||||
text = text.Remove(firstIndex, endTag.Length).Insert(firstIndex, "<i>");
|
||||
@ -2709,9 +2709,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
bool isStart = false;
|
||||
bool isEnd = false;
|
||||
if(text.StartsWith(startTag) || text.StartsWith(s1) || text.StartsWith(s2) || text.StartsWith(s3) || text.StartsWith(s4))
|
||||
if (text.StartsWith(startTag, StringComparison.Ordinal) || text.StartsWith(s1, StringComparison.Ordinal) || text.StartsWith(s2, StringComparison.Ordinal) || text.StartsWith(s3, StringComparison.Ordinal) || text.StartsWith(s4, StringComparison.Ordinal))
|
||||
isStart = true;
|
||||
if (text.EndsWith(endTag) || text.EndsWith(e1) || text.EndsWith(e2) || text.EndsWith(e3) || text.EndsWith(e4) || text.EndsWith(e5))
|
||||
if (text.EndsWith(endTag, StringComparison.Ordinal) || text.EndsWith(e1, StringComparison.Ordinal) || text.EndsWith(e2, StringComparison.Ordinal) || text.EndsWith(e3, StringComparison.Ordinal) || text.EndsWith(e4, StringComparison.Ordinal) || text.EndsWith(e5, StringComparison.Ordinal))
|
||||
isEnd = true;
|
||||
return isStart && isEnd;
|
||||
}
|
||||
@ -3995,10 +3995,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return text;
|
||||
|
||||
if (text.StartsWith("\"") && text.Length > 1)
|
||||
if (text.StartsWith("\"", StringComparison.Ordinal) && text.Length > 1)
|
||||
text = text.Substring(1);
|
||||
|
||||
if (text.EndsWith("\"") && text.Length >= 1)
|
||||
if (text.EndsWith("\"", StringComparison.Ordinal) && text.Length >= 1)
|
||||
text = text.Substring(0, text.Length - 1);
|
||||
|
||||
return text.Replace("\"\"", "\"");
|
||||
@ -4214,7 +4214,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (text.Contains(" " + Environment.NewLine))
|
||||
text = text.Replace(" " + Environment.NewLine, Environment.NewLine);
|
||||
|
||||
if (text.EndsWith(" "))
|
||||
if (text.EndsWith(" ", StringComparison.Ordinal))
|
||||
text = text.TrimEnd(' ');
|
||||
|
||||
text = text.Replace(". . ..", "...");
|
||||
@ -4232,11 +4232,11 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
text = text.Replace(Environment.NewLine + "- ... ", Environment.NewLine + "- ...");
|
||||
text = text.Replace(Environment.NewLine + "<i>- ... ", Environment.NewLine + "<i>- ...");
|
||||
|
||||
if (text.StartsWith("... "))
|
||||
if (text.StartsWith("... ", StringComparison.Ordinal))
|
||||
text = text.Remove(3, 1);
|
||||
if (text.EndsWith(" ..."))
|
||||
if (text.EndsWith(" ...", StringComparison.Ordinal))
|
||||
text = text.Remove(text.Length - 4, 1);
|
||||
if (text.EndsWith(" ...</i>"))
|
||||
if (text.EndsWith(" ...</i>", StringComparison.Ordinal))
|
||||
text = text.Remove(text.Length - 8, 1);
|
||||
|
||||
if (language != "fr") // special rules for French
|
||||
@ -4254,10 +4254,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
while (text.Contains(" ,"))
|
||||
text = text.Replace(" ,", ",");
|
||||
|
||||
if (text.EndsWith(" ."))
|
||||
if (text.EndsWith(" .", StringComparison.Ordinal))
|
||||
text = text.Substring(0, text.Length - " .".Length) + ".";
|
||||
|
||||
if (text.EndsWith(" \""))
|
||||
if (text.EndsWith(" \"", StringComparison.Ordinal))
|
||||
text = text.Remove(text.Length - 2, 1);
|
||||
|
||||
if (text.Contains(" \"" + Environment.NewLine))
|
||||
@ -4288,13 +4288,13 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (text.Contains("? </i>" + Environment.NewLine))
|
||||
text = text.Replace("? </i>" + Environment.NewLine, "?</i>" + Environment.NewLine);
|
||||
|
||||
if (text.EndsWith(" </i>"))
|
||||
if (text.EndsWith(" </i>", StringComparison.Ordinal))
|
||||
text = text.Substring(0, text.Length - " </i>".Length) + "</i>";
|
||||
|
||||
if (text.Contains(" </i>" + Environment.NewLine))
|
||||
text = text.Replace(" </i>" + Environment.NewLine, "</i>" + Environment.NewLine);
|
||||
|
||||
if (text.EndsWith(" </I>"))
|
||||
if (text.EndsWith(" </I>", StringComparison.Ordinal))
|
||||
text = text.Substring(0, text.Length - " </I>".Length) + "</I>";
|
||||
|
||||
if (text.Contains(" </I>" + Environment.NewLine))
|
||||
|
@ -493,7 +493,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
|
||||
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation))
|
||||
{
|
||||
if (Configuration.Settings.General.VlcLocation.ToUpper().EndsWith(".exe"))
|
||||
if (Configuration.Settings.General.VlcLocation.ToUpper().EndsWith(".exe", StringComparison.Ordinal))
|
||||
Configuration.Settings.General.VlcLocation = Path.GetDirectoryName(Configuration.Settings.General.VlcLocation);
|
||||
|
||||
path = Path.Combine(Configuration.Settings.General.VlcLocation, fileName);
|
||||
@ -506,7 +506,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
|
||||
try
|
||||
{
|
||||
path = Configuration.Settings.General.VlcLocationRelative;
|
||||
if (path.ToUpper().EndsWith(".exe"))
|
||||
if (path.ToUpper().EndsWith(".exe", StringComparison.Ordinal))
|
||||
path = Path.GetDirectoryName(path);
|
||||
|
||||
path = Path.Combine(path, fileName);
|
||||
|
Loading…
Reference in New Issue
Block a user