diff --git a/src/libse/Common/StrippableText.cs b/src/libse/Common/StrippableText.cs index b0e0a88a3a..41876cbfe4 100644 --- a/src/libse/Common/StrippableText.cs +++ b/src/libse/Common/StrippableText.cs @@ -4,8 +4,11 @@ namespace Nikse.SubtitleEdit.Core.Common { - public class StrippableText + public struct StrippableText { + private const string PrefixChars = " >-\"„”“['‘`´¶(♪¿¡.…—"; + private const string SuffixChars = " -\"”“]'`´¶)♪.!?:…—؛،؟"; + public string Pre { get; set; } public string Post { get; set; } public string StrippedText { get; set; } @@ -14,7 +17,7 @@ public class StrippableText public string MergedString => Pre + StrippedText + Post; public StrippableText(string text) - : this(text, " >-\"„”“['‘`´¶(♪¿¡.…—", " -\"”“]'`´¶)♪.!?:…—؛،؟") + : this(text, PrefixChars, SuffixChars) { } @@ -58,8 +61,7 @@ public StrippableText(string input, string stripStartCharacters, string stripEnd Pre += text.Substring(0, endIndex); text = text.Remove(0, endIndex); } - } - while (text.Length < beginLength); + } while (text.Length < beginLength); } Post = string.Empty; @@ -94,8 +96,7 @@ public StrippableText(string input, string stripStartCharacters, string stripEnd text = text.Substring(0, text.Length - 7); } } - } - while (text.Length < beginLength); + } while (text.Length < beginLength); } StrippedText = text; @@ -151,6 +152,7 @@ private void ReplaceNames1Remove(List nameList, List replaceIds, lower = StrippedText.ToLowerInvariant(); } } + if (start + 3 > lower.Length) { start = lower.Length + 1; @@ -178,6 +180,7 @@ private void ReplaceNames2Fix(List replaceIds, List replaceNames } private static readonly char[] ExpectedCharsArray = { '.', '!', '?', ':', ';', ')', ']', '}', '(', '[', '{' }; + public void FixCasing(List nameList, bool changeNameCases, bool makeUppercaseAfterBreak, bool checkLastLine, string lastLine, double millisecondsFromLast = 0) { var replaceIds = new List(); @@ -324,6 +327,7 @@ public void FixCasing(List nameList, bool changeNameCases, bool makeUppe } } } + StrippedText = sb.ToString(); } @@ -389,6 +393,7 @@ private bool ShouldStartWithUpperCase(string lastLine, double millisecondsgaps) lastChar = tempPreLine[tempPreLine.Length - 1]; } } + if (lastChar == '.' || lastChar == '!' || lastChar == '?' || lastChar == ']' || lastChar == ')' || lastChar == ':' || lastChar == '_') { return true; @@ -404,4 +409,4 @@ private bool ShouldStartWithUpperCase(string lastLine, double millisecondsgaps) return false; } } -} +} \ No newline at end of file