mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Minor refact
This commit is contained in:
parent
3400e17dd7
commit
c02f3287ab
@ -295,7 +295,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
word = word.Replace('´', '\'');
|
||||
word = word.Replace('‘', '\'');
|
||||
word = word.Replace('—', '-');
|
||||
while(word.Contains("--"))
|
||||
while (word.Contains("--"))
|
||||
word = word.Replace("--", "-");
|
||||
word = word.Replace('|', 'l');
|
||||
word = word.Replace("vx/", "w");
|
||||
@ -349,7 +349,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
pre += "<i>";
|
||||
word = word.Remove(0, 3);
|
||||
}
|
||||
while (word.Length > 2 && word.EndsWith(Environment.NewLine))
|
||||
while (word.Length > 2 && word.EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
post += Environment.NewLine;
|
||||
word = word.Substring(0, word.Length - 2);
|
||||
@ -484,8 +484,8 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
{
|
||||
if (word[match.Index + 1] == 'I' || word[match.Index + 1] == '1')
|
||||
{
|
||||
bool doFix = word[match.Index + 1] != 'I' && match.Index >= 1 && word.Substring(match.Index - 1).StartsWith("Mc");
|
||||
if (word[match.Index + 1] == 'I' && match.Index >= 2 && word.Substring(match.Index - 2).StartsWith("Mac"))
|
||||
bool doFix = word[match.Index + 1] != 'I' && match.Index >= 1 && word.Substring(match.Index - 1).StartsWith("Mc", StringComparison.Ordinal);
|
||||
if (word[match.Index + 1] == 'I' && match.Index >= 2 && word.Substring(match.Index - 2).StartsWith("Mac", StringComparison.Ordinal))
|
||||
doFix = false;
|
||||
|
||||
if (doFix)
|
||||
@ -566,7 +566,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
pre += "<i>";
|
||||
word = word.Remove(0, 3);
|
||||
}
|
||||
while (word.StartsWith(Environment.NewLine) && word.Length > 2)
|
||||
while (word.StartsWith(Environment.NewLine, StringComparison.Ordinal) && word.Length > 2)
|
||||
{
|
||||
pre += Environment.NewLine;
|
||||
word = word.Substring(2);
|
||||
@ -597,7 +597,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
pre += "<i>";
|
||||
word = word.Remove(0, 3);
|
||||
}
|
||||
while (word.EndsWith(Environment.NewLine) && word.Length > 2)
|
||||
while (word.EndsWith(Environment.NewLine, StringComparison.Ordinal) && word.Length > 2)
|
||||
{
|
||||
post += Environment.NewLine;
|
||||
word = word.Substring(0, word.Length - 2);
|
||||
@ -911,7 +911,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
int appendFrom = 0;
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (text.Substring(i).StartsWith(word) && i >= appendFrom)
|
||||
if (text.Substring(i).StartsWith(word, StringComparison.Ordinal) && i >= appendFrom)
|
||||
{
|
||||
bool startOk = i == 0;
|
||||
if (!startOk)
|
||||
|
@ -202,7 +202,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
if (p.Text.Length > 5 && p.Text.Contains(new[] { '#', '♪', '♫' }))
|
||||
{
|
||||
string newText = p.Text;
|
||||
if (@"#♪♫".Contains(newText[0]) && !@" <".Contains(newText[1]) && !newText.Substring(1).StartsWith(Environment.NewLine) &&
|
||||
if (@"#♪♫".Contains(newText[0]) && !@" <".Contains(newText[1]) && !newText.Substring(1).StartsWith(Environment.NewLine, StringComparison.Ordinal) &&
|
||||
!newText.Substring(1).StartsWith('♪') && !newText.Substring(1).StartsWith('♫'))
|
||||
newText = newText.Insert(1, " ");
|
||||
if (@"#♪♫".Contains(newText[newText.Length - 1]) && !@" >".Contains(newText[newText.Length - 2]) &&
|
||||
@ -316,45 +316,45 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
|
||||
private static bool IsSwedishSkipValue(string languageCode, Match match)
|
||||
{
|
||||
return languageCode == "sv" && (match.Value.EndsWith(":e") ||
|
||||
match.Value.EndsWith(":a") ||
|
||||
match.Value.EndsWith(":et") ||
|
||||
match.Value.EndsWith(":en") ||
|
||||
match.Value.EndsWith(":n") ||
|
||||
match.Value.EndsWith(":s"));
|
||||
return languageCode == "sv" && (match.Value.EndsWith(":e", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":a", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":et", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":en", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":n", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":s", StringComparison.Ordinal));
|
||||
}
|
||||
private static bool IsFinnishSkipValue(string languageCode, Match match)
|
||||
{
|
||||
return languageCode == "fi" && (match.Value.EndsWith(":aa") ||
|
||||
match.Value.EndsWith(":aan") ||
|
||||
match.Value.EndsWith(":een") ||
|
||||
match.Value.EndsWith(":ia") ||
|
||||
match.Value.EndsWith(":ien") ||
|
||||
match.Value.EndsWith(":iksi") ||
|
||||
match.Value.EndsWith(":ille") ||
|
||||
match.Value.EndsWith(":een") ||
|
||||
match.Value.EndsWith(":in") ||
|
||||
match.Value.EndsWith(":ina") ||
|
||||
match.Value.EndsWith(":inä") ||
|
||||
match.Value.EndsWith(":itta") ||
|
||||
match.Value.EndsWith(":ittä") ||
|
||||
match.Value.EndsWith(":iä") ||
|
||||
match.Value.EndsWith(":ksi") ||
|
||||
match.Value.EndsWith(":lta") ||
|
||||
match.Value.EndsWith(":ltä") ||
|
||||
match.Value.EndsWith(":n") ||
|
||||
match.Value.EndsWith(":nä") ||
|
||||
match.Value.EndsWith(":ssa") ||
|
||||
match.Value.EndsWith(":ssä") ||
|
||||
match.Value.EndsWith(":sta") ||
|
||||
match.Value.EndsWith(":stä") ||
|
||||
match.Value.EndsWith(":t") ||
|
||||
match.Value.EndsWith(":ta") ||
|
||||
match.Value.EndsWith(":tta") ||
|
||||
match.Value.EndsWith(":ttä") ||
|
||||
match.Value.EndsWith(":tä") ||
|
||||
match.Value.EndsWith(":ää") ||
|
||||
match.Value.EndsWith(":ään"));
|
||||
return languageCode == "fi" && (match.Value.EndsWith(":aa", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":aan", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":een", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ia", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ien", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":iksi", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ille", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":een", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":in", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ina", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":inä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":itta", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ittä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":iä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ksi", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":lta", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ltä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":n", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":nä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ssa", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ssä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":sta", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":stä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":t", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ta", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":tta", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ttä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":tä", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ää", StringComparison.Ordinal) ||
|
||||
match.Value.EndsWith(":ään", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private static string GetWordFromIndex(string text, int index)
|
||||
|
@ -128,7 +128,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
for (int i = 0; i < csv.Length; i++)
|
||||
{
|
||||
var s = csv[i];
|
||||
if (s == '"' && csv.Substring(i).StartsWith("\"\""))
|
||||
if (s == '"' && csv.Substring(i).StartsWith("\"\"", StringComparison.Ordinal))
|
||||
{
|
||||
sb.Append('"');
|
||||
}
|
||||
@ -138,7 +138,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
isBreak = false;
|
||||
}
|
||||
else if (i == 0 || i == csv.Length - 1 || sb.ToString().EndsWith(Environment.NewLine))
|
||||
else if (i == 0 || i == csv.Length - 1 || sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
sb.Append('"');
|
||||
}
|
||||
|
@ -710,19 +710,19 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string s = text.Substring(i, 1);
|
||||
int index = Letters.IndexOf(s);
|
||||
string newCode;
|
||||
if (text.Substring(i).StartsWith("<i>"))
|
||||
if (text.Substring(i).StartsWith("<i>", StringComparison.Ordinal))
|
||||
{
|
||||
newCode = "91ae";
|
||||
i += 2;
|
||||
italic++;
|
||||
}
|
||||
else if (text.Substring(i).StartsWith("</i>") && italic > 0)
|
||||
else if (text.Substring(i).StartsWith("</i>", StringComparison.Ordinal) && italic > 0)
|
||||
{
|
||||
newCode = "9120";
|
||||
i += 3;
|
||||
italic--;
|
||||
}
|
||||
else if (text.Substring(i).StartsWith("’"))
|
||||
else if (text[i] == '’')
|
||||
{
|
||||
if (code.Length == 4)
|
||||
{
|
||||
@ -1691,7 +1691,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var cp = GetColorAndPosition(part);
|
||||
if (cp != null)
|
||||
{
|
||||
if (cp.Y > 0 && y >= 0 && cp.Y > y && !sb.ToString().EndsWith(Environment.NewLine) && !string.IsNullOrWhiteSpace(sb.ToString()))
|
||||
if (cp.Y > 0 && y >= 0 && cp.Y > y && !sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal) && !string.IsNullOrWhiteSpace(sb.ToString()))
|
||||
sb.AppendLine();
|
||||
if (cp.Y > 0)
|
||||
y = cp.Y;
|
||||
@ -1712,7 +1712,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
case "9440":
|
||||
case "94e0":
|
||||
if (!sb.ToString().EndsWith(Environment.NewLine))
|
||||
if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
sb.AppendLine();
|
||||
break;
|
||||
case "2c75":
|
||||
|
@ -394,7 +394,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
isItalic = false;
|
||||
i += 3;
|
||||
}
|
||||
else if (text.Substring(i).StartsWith(Environment.NewLine))
|
||||
else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
|
||||
|
||||
|
@ -16909,14 +16909,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string pre = string.Empty;
|
||||
// There is text selected
|
||||
text = tb.SelectedText;
|
||||
while (text.EndsWith(' ') || text.EndsWith(Environment.NewLine) || text.StartsWith(' ') || text.StartsWith(Environment.NewLine))
|
||||
while (text.EndsWith(' ') || text.EndsWith(Environment.NewLine, StringComparison.Ordinal) || text.StartsWith(' ') || text.StartsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
if (text.EndsWith(' '))
|
||||
{
|
||||
post += " ";
|
||||
text = text.Remove(text.Length - 1);
|
||||
}
|
||||
if (text.EndsWith(Environment.NewLine))
|
||||
if (text.EndsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
post += Environment.NewLine;
|
||||
text = text.Remove(text.Length - 2);
|
||||
@ -16926,7 +16926,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
pre += " ";
|
||||
text = text.Remove(0, 1);
|
||||
}
|
||||
if (text.StartsWith(Environment.NewLine))
|
||||
if (text.StartsWith(Environment.NewLine, StringComparison.Ordinal))
|
||||
{
|
||||
pre += Environment.NewLine;
|
||||
text = text.Remove(0, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user