diff --git a/src/Controls/SETextBox.cs b/src/Controls/SETextBox.cs index 6722a3035..ab63dea3a 100644 --- a/src/Controls/SETextBox.cs +++ b/src/Controls/SETextBox.cs @@ -42,13 +42,13 @@ namespace Nikse.SubtitleEdit.Controls { if (s[deleteFrom] == ' ') deleteFrom--; - while (deleteFrom > 0 && !(breakChars).Contains(s.Substring(deleteFrom, 1))) + while (deleteFrom > 0 && !breakChars.Contains(s[deleteFrom])) { deleteFrom--; } if (deleteFrom == index - 1) { - while (deleteFrom > 0 && (breakChars.Replace(" ", string.Empty)).Contains(s.Substring(deleteFrom - 1, 1))) + while (deleteFrom > 0 && breakChars.Replace(" ", string.Empty).Contains(s[deleteFrom - 1])) { deleteFrom--; } @@ -152,7 +152,7 @@ namespace Nikse.SubtitleEdit.Controls if (_dragStartFrom < index) index--; } - else if (_dragStartFrom > 0 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && ";:]<.!?".Contains(Text[_dragStartFrom + 1].ToString())) + else if (_dragStartFrom > 0 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && @";:]<.!?".Contains(Text[_dragStartFrom + 1])) { Text = Text.Remove(_dragStartFrom, 1); if (_dragStartFrom < index) @@ -192,7 +192,7 @@ namespace Nikse.SubtitleEdit.Controls // fix end spaces if (endIndex < Text.Length && !newText.EndsWith(' ') && Text[endIndex] != ' ') { - bool lastWord = ";:]<.!?".Contains(Text[endIndex].ToString()); + bool lastWord = @";:]<.!?".Contains(Text[endIndex]); if (!lastWord) Text = Text.Insert(endIndex, " "); } @@ -248,12 +248,12 @@ namespace Nikse.SubtitleEdit.Controls { int selectionLength = 0; int i = tb.SelectionStart; - while (i > 0 && breakChars.Contains(tb.Text.Substring(i - 1, 1)) == false) + while (i > 0 && !breakChars.Contains(tb.Text[i - 1])) i--; tb.SelectionStart = i; for (; i < tb.Text.Length; i++) { - if (breakChars.Contains(tb.Text.Substring(i, 1))) + if (breakChars.Contains(tb.Text[i])) break; selectionLength++; } diff --git a/src/Controls/VideoPlayerContainer.cs b/src/Controls/VideoPlayerContainer.cs index 2ee33fd78..2ec34d9fc 100644 --- a/src/Controls/VideoPlayerContainer.cs +++ b/src/Controls/VideoPlayerContainer.cs @@ -411,13 +411,13 @@ namespace Nikse.SubtitleEdit.Controls isFontColor = false; i += 6; } - else if (text.Substring(i, 1) == "\n") // RichTextBox only count NewLine as one character! + else if (text[i] == '\n') // RichTextBox only count NewLine as one character! { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); letterCount++; } i++; diff --git a/src/Forms/AddToNames.cs b/src/Forms/AddToNames.cs index e85048e38..d191491b1 100644 --- a/src/Forms/AddToNames.cs +++ b/src/Forms/AddToNames.cs @@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Forms { textBoxAddName.Text = text.Trim().TrimEnd('.').TrimEnd('!').TrimEnd('?'); if (textBoxAddName.Text.Length > 1) - textBoxAddName.Text = textBoxAddName.Text.Substring(0, 1).ToUpper() + textBoxAddName.Text.Substring(1); + textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); } comboBoxDictionaries.Items.Clear(); @@ -67,7 +67,7 @@ namespace Nikse.SubtitleEdit.Forms { textBoxAddName.Text = text.Trim().TrimEnd('.').TrimEnd('!').TrimEnd('?'); if (textBoxAddName.Text.Length > 1) - textBoxAddName.Text = textBoxAddName.Text.Substring(0, 1).ToUpper() + textBoxAddName.Text.Substring(1); + textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); } comboBoxDictionaries.Items.Clear(); diff --git a/src/Forms/AddWaveForm.cs b/src/Forms/AddWaveForm.cs index fbe48dd69..c2f589223 100644 --- a/src/Forms/AddWaveForm.cs +++ b/src/Forms/AddWaveForm.cs @@ -52,14 +52,14 @@ namespace Nikse.SubtitleEdit.Forms _cancel = false; bool runningOnWindows = false; SourceVideoFileName = labelVideoFileName.Text; - string targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".wav"); - string parameters = "\"" + SourceVideoFileName + "\" -I dummy -vvv --no-sout-video --audio-track=" + _audioTrackNumber.ToString() + " --sout=\"#transcode{acodec=s16l,channels=1,ab=128}:std{access=file,mux=wav,dst=" + targetFile + "}\" vlc://quit"; - // string parameters = "\"" + SourceVideoFileName + "\" -I dummy -vvv --no-sout-video --audio-track=" + _audioTrackNumber.ToString() + " --sout=\"#transcode{acodec=s16l,channels=2,ab=128,samplerate=24000}:std{access=file,mux=wav,dst=" + targetFile + "}\" vlc://quit"; + string targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav"); + string parameters = "\"" + SourceVideoFileName + "\" -I dummy -vvv --no-sout-video --audio-track=" + _audioTrackNumber + " --sout=\"#transcode{acodec=s16l,channels=1,ab=128}:std{access=file,mux=wav,dst=" + targetFile + "}\" vlc://quit"; + //string parameters = "\"" + SourceVideoFileName + "\" -I dummy -vvv --no-sout-video --audio-track=" + _audioTrackNumber + " --sout=\"#transcode{acodec=s16l,channels=2,ab=128,samplerate=24000}:std{access=file,mux=wav,dst=" + targetFile + "}\" vlc://quit"; string exeFilePath; if (Utilities.IsRunningOnLinux() || Utilities.IsRunningOnMac()) { exeFilePath = "cvlc"; - parameters = "-vvv --no-sout-video --audio-track=" + _audioTrackNumber.ToString() + " --sout '#transcode{" + _encodeParamters + "}:std{mux=wav,access=file,dst=" + targetFile + "}' \"" + SourceVideoFileName + "\" vlc://quit"; + parameters = "-vvv --no-sout-video --audio-track=" + _audioTrackNumber + " --sout '#transcode{" + _encodeParamters + "}:std{mux=wav,access=file,dst=" + targetFile + "}' \"" + SourceVideoFileName + "\" vlc://quit"; } else // windows { @@ -258,7 +258,7 @@ namespace Nikse.SubtitleEdit.Forms if (ti.CodecId != null && ti.Language != null) audioTrackNames.Add("#" + ti.TrackNumber + ": " + ti.CodecId.Replace("\0", string.Empty) + " - " + ti.Language.Replace("\0", string.Empty)); else - audioTrackNames.Add("#" + ti.TrackNumber.ToString()); + audioTrackNames.Add("#" + ti.TrackNumber); mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, ti.TrackNumber); } } diff --git a/src/Forms/AdjustDisplayDuration.cs b/src/Forms/AdjustDisplayDuration.cs index 5731458f2..4d32b29e9 100644 --- a/src/Forms/AdjustDisplayDuration.cs +++ b/src/Forms/AdjustDisplayDuration.cs @@ -15,7 +15,7 @@ namespace Nikse.SubtitleEdit.Forms if (radioButtonPercent.Checked) return comboBoxPercent.Text; if (radioButtonAutoRecalculate.Checked) - return radioButtonAutoRecalculate.Text + ", " + labelMaxCharsPerSecond.Text + ": " + numericUpDownMaxCharsSec.Value.ToString(); //TODO: Make language string with string.Format + return radioButtonAutoRecalculate.Text + ", " + labelMaxCharsPerSecond.Text + ": " + numericUpDownMaxCharsSec.Value; //TODO: Make language string with string.Format return comboBoxSeconds.Text; } } diff --git a/src/Forms/Beamer.cs b/src/Forms/Beamer.cs index 3f032fd80..da41f82b0 100644 --- a/src/Forms/Beamer.cs +++ b/src/Forms/Beamer.cs @@ -408,7 +408,7 @@ namespace Nikse.SubtitleEdit.Forms } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } i++; } diff --git a/src/Forms/ChangeCasingNames.cs b/src/Forms/ChangeCasingNames.cs index 56085597d..5931ae471 100644 --- a/src/Forms/ChangeCasingNames.cs +++ b/src/Forms/ChangeCasingNames.cs @@ -166,7 +166,7 @@ namespace Nikse.SubtitleEdit.Forms int end = startIndex + name.Length; bool endOk = end <= text.Length; if (endOk) - endOk = (end == text.Length) || ((" ,.!?:;')-<\"" + Environment.NewLine).Contains(text[end].ToString(CultureInfo.InvariantCulture))); + endOk = end == text.Length || (@" ,.!?:;')-<""" + Environment.NewLine).Contains(text[end]); if (endOk && text.Substring(startIndex, name.Length) != name) // do not add names where casing already is correct { @@ -207,14 +207,14 @@ namespace Nikse.SubtitleEdit.Forms if (start >= 0) { 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(CultureInfo.InvariantCulture))); + lower[start - 1] == '\'' || lower[start - 1] == '>' || Environment.NewLine.EndsWith(lower[start - 1]); if (startOk) { int end = start + name.Length; bool endOk = end <= lower.Length; if (endOk) - endOk = end == lower.Length || (" ,.!?:;')<-\"" + Environment.NewLine).Contains(lower[end].ToString(CultureInfo.InvariantCulture)); + endOk = end == lower.Length || (@" ,.!?:;')<-""" + Environment.NewLine).Contains(lower[end]); item.Selected = endOk; } diff --git a/src/Forms/ChooseLanguage.cs b/src/Forms/ChooseLanguage.cs index 0366c7337..0a2288f25 100644 --- a/src/Forms/ChooseLanguage.cs +++ b/src/Forms/ChooseLanguage.cs @@ -22,7 +22,7 @@ namespace Nikse.SubtitleEdit.Forms public override string ToString() { - return _cultureInfo.NativeName[0].ToString().ToUpper() + _cultureInfo.NativeName.Substring(1); + return char.ToUpper(_cultureInfo.NativeName[0]) + _cultureInfo.NativeName.Substring(1); } public string Name diff --git a/src/Forms/EbuSaveOptions.cs b/src/Forms/EbuSaveOptions.cs index 49f012a1a..5d5a7bd30 100644 --- a/src/Forms/EbuSaveOptions.cs +++ b/src/Forms/EbuSaveOptions.cs @@ -185,7 +185,7 @@ namespace Nikse.SubtitleEdit.Forms else _header.DisplayStandardCode = " "; - _header.CharacterCodeTableNumber = "0" + comboBoxCharacterCodeTable.SelectedIndex.ToString(); + _header.CharacterCodeTableNumber = "0" + comboBoxCharacterCodeTable.SelectedIndex; _header.LanguageCode = textBoxLanguageCode.Text; if (_header.LanguageCode.Length != 2) _header.LanguageCode = "0A"; @@ -198,9 +198,9 @@ namespace Nikse.SubtitleEdit.Forms _header.CountryOfOrigin = textBoxCountryOfOrigin.Text; if (_header.CountryOfOrigin.Length != 3) _header.CountryOfOrigin = "USA"; - _header.RevisionNumber = numericUpDownRevisionNumber.Value.ToString().PadLeft(2, '0'); - _header.MaximumNumberOfDisplayableCharactersInAnyTextRow = numericUpDownMaxCharacters.Value.ToString().PadLeft(2, '0'); - _header.MaximumNumberOfDisplayableRows = numericUpDownMaxRows.Value.ToString().PadLeft(2, '0'); + _header.RevisionNumber = numericUpDownRevisionNumber.Value.ToString("D2"); + _header.MaximumNumberOfDisplayableCharactersInAnyTextRow = numericUpDownMaxCharacters.Value.ToString("D2"); + _header.MaximumNumberOfDisplayableRows = numericUpDownMaxRows.Value.ToString("D2"); _header.DiskSequenceNumber = numericUpDownDiskSequenceNumber.Value.ToString(); _header.TotalNumberOfDisks = numericUpDownTotalNumberOfDiscs.Value.ToString(); JustificationCode = (byte)comboBoxJustificationCode.SelectedIndex; diff --git a/src/Forms/EffectKaraoke.cs b/src/Forms/EffectKaraoke.cs index 98741123e..ccee8da2a 100644 --- a/src/Forms/EffectKaraoke.cs +++ b/src/Forms/EffectKaraoke.cs @@ -113,11 +113,11 @@ namespace Nikse.SubtitleEdit.Forms string tempColor = string.Empty; int start = tag.IndexOf(colorTag); int j = start + colorTag.Length; - if ("\"'".Contains(tag[j].ToString())) + if (@"""'".Contains(tag[j])) j++; - while (j < tag.Length && ("#" + Utilities.LowercaseLettersWithNumbers).Contains(tag[j].ToString())) + while (j < tag.Length && (@"#" + Utilities.LowercaseLettersWithNumbers).Contains(tag[j])) { - tempColor += tag[j].ToString(); + tempColor += tag[j]; j++; } if (!string.IsNullOrEmpty(currentColor)) diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs index 0d68cc02c..102f7e74e 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/Forms/ExportPngXml.cs @@ -1642,7 +1642,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } i++; } @@ -2201,7 +2201,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } i++; } diff --git a/src/Forms/ExportText.cs b/src/Forms/ExportText.cs index 717fe0a09..16dde28b2 100644 --- a/src/Forms/ExportText.cs +++ b/src/Forms/ExportText.cs @@ -89,7 +89,7 @@ namespace Nikse.SubtitleEdit.Forms { if (showLineNumbers) { - sb.Append(p.Number.ToString()); + sb.Append(p.Number); if (addNewlineAfterLineNumber) sb.AppendLine(); else @@ -102,7 +102,7 @@ namespace Nikse.SubtitleEdit.Forms else if (timeCodeHHMMSSFF) sb.Append(p.StartTime.ToHHMMSSFF() + timeCodeSeperator + p.EndTime.ToHHMMSSFF()); else - sb.Append(p.StartTime.TotalMilliseconds.ToString() + timeCodeSeperator + p.EndTime.TotalMilliseconds.ToString()); + sb.Append(p.StartTime.TotalMilliseconds + timeCodeSeperator + p.EndTime.TotalMilliseconds); if (addNewlineAfterTimeCodes) sb.AppendLine(); diff --git a/src/Forms/FixCommonErrors.cs b/src/Forms/FixCommonErrors.cs index 77a8d4087..f52523643 100644 --- a/src/Forms/FixCommonErrors.cs +++ b/src/Forms/FixCommonErrors.cs @@ -1333,7 +1333,7 @@ namespace Nikse.SubtitleEdit.Forms { while (match.Success) { - if ("\"”<.".Contains(p.Text[match.Index + 2].ToString()) == false) + if (!@"""”<.".Contains(p.Text[match.Index + 2])) { if (AllowFix(p, fixAction)) { @@ -1355,7 +1355,7 @@ namespace Nikse.SubtitleEdit.Forms { while (match.Success) { - if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) + if (!@"""<".Contains(p.Text[match.Index + 2])) { if (AllowFix(p, fixAction)) { @@ -1377,7 +1377,7 @@ namespace Nikse.SubtitleEdit.Forms { while (match.Success) { - if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) + if (!@"""<".Contains(p.Text[match.Index + 2])) { if (AllowFix(p, fixAction)) { @@ -1409,7 +1409,7 @@ namespace Nikse.SubtitleEdit.Forms { // we are inside a tag: like indexOfEndCodeTag "{y:i}Is this italic?" } - else if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) + else if (!@"""<".Contains(p.Text[match.Index + 2])) { if (AllowFix(p, fixAction)) { @@ -1499,7 +1499,7 @@ namespace Nikse.SubtitleEdit.Forms { string newText = p.Text; int indexOfFontTag = newText.ToLower().IndexOf(" 0 && !(Environment.NewLine + " >[(♪♫¿").Contains(p.Text[start - 1].ToString())) + if (start > 0 && !(Environment.NewLine + @" >[(♪♫¿").Contains(p.Text[start - 1])) { if (indexOfFontTag == -1 || start > newText.IndexOf('>', indexOfFontTag)) // font tags can contain " { @@ -1507,7 +1507,7 @@ namespace Nikse.SubtitleEdit.Forms end++; } } - if (end < newText.Length - 2 && !(Environment.NewLine + " <,.!?:;])♪♫¿").Contains(p.Text[end + 1].ToString())) + if (end < newText.Length - 2 && !(Environment.NewLine + @" <,.!?:;])♪♫¿").Contains(p.Text[end + 1])) { if (indexOfFontTag == -1 || end > newText.IndexOf('>', indexOfFontTag)) // font tags can contain " { @@ -1530,10 +1530,10 @@ namespace Nikse.SubtitleEdit.Forms if ((p.Text.Contains('#') || p.Text.Contains('♪') || p.Text.Contains('♫')) && p.Text.Length > 5) { string newText = p.Text; - if ("#♪♫".Contains(newText[0].ToString()) && !" <".Contains(newText[1].ToString()) && !newText.Substring(1).StartsWith(Environment.NewLine) && + if (@"#♪♫".Contains(newText[0]) && !@" <".Contains(newText[1]) && !newText.Substring(1).StartsWith(Environment.NewLine) && !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()) && + if (@"#♪♫".Contains(newText[newText.Length - 1]) && !@" >".Contains(newText[newText.Length - 2]) && !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('♫')) newText = newText.Insert(newText.Length - 1, " "); @@ -1557,8 +1557,8 @@ namespace Nikse.SubtitleEdit.Forms { if (newText.Length > index + 4 && index > 1) { - if (Utilities.AllLettersAndNumbers.Contains(newText[index + 3].ToString()) && - Utilities.AllLettersAndNumbers.Contains(newText[index - 1].ToString())) + if (Utilities.AllLettersAndNumbers.Contains(newText[index + 3]) && + Utilities.AllLettersAndNumbers.Contains(newText[index - 1])) newText = newText.Insert(index + 3, " "); } index = newText.IndexOf("...", index + 2, StringComparison.Ordinal); @@ -1583,8 +1583,8 @@ namespace Nikse.SubtitleEdit.Forms { if (newText.Length > index + 6 && index > 1) { - if (Utilities.AllLettersAndNumbers.Contains(newText[index + 3].ToString()) && - Utilities.AllLettersAndNumbers.Contains(newText[index - 1].ToString())) + if (Utilities.AllLettersAndNumbers.Contains(newText[index + 3]) && + Utilities.AllLettersAndNumbers.Contains(newText[index - 1])) newText = newText.Insert(index, " "); } index = newText.IndexOf("", index + 3, StringComparison.Ordinal); @@ -1609,8 +1609,8 @@ namespace Nikse.SubtitleEdit.Forms { if (newText.Length > index + 6 && index > 1) { - if (Utilities.AllLettersAndNumbers.Contains(newText[index + 4].ToString()) && - Utilities.AllLettersAndNumbers.Contains(newText[index - 1].ToString())) + if (Utilities.AllLettersAndNumbers.Contains(newText[index + 4]) && + Utilities.AllLettersAndNumbers.Contains(newText[index - 1])) newText = newText.Insert(index + 4, " "); } index = newText.IndexOf("", index + 4, StringComparison.Ordinal); @@ -1632,10 +1632,9 @@ namespace Nikse.SubtitleEdit.Forms int j = 1; while (j < newText.Length) { - string ch = newText.Substring(j, 1); - if ("!?:;".Contains(ch)) + if (@"!?:;".Contains(newText[j])) { - if (Utilities.AllLetters.Contains(newText.Substring(j - 1, 1))) + if (Utilities.AllLetters.Contains(newText[j - 1])) { newText = newText.Insert(j, " "); j++; @@ -1667,7 +1666,7 @@ namespace Nikse.SubtitleEdit.Forms int endIndex = index; for (int i = index; i < text.Length; i++) { - if ((" " + Environment.NewLine).Contains(text[i].ToString())) + if ((@" " + Environment.NewLine).Contains(text[i])) break; endIndex = i; } @@ -1675,13 +1674,12 @@ namespace Nikse.SubtitleEdit.Forms int startIndex = index; for (int i = index; i >= 0; i--) { - if ((" " + Environment.NewLine).Contains(text[i].ToString())) + if ((@" " + Environment.NewLine).Contains(text[i])) break; startIndex = i; } - string s = text.Substring(startIndex, endIndex - startIndex + 1); - return s; + return text.Substring(startIndex, endIndex - startIndex + 1); } public void AddMissingQuotes() @@ -1855,11 +1853,11 @@ namespace Nikse.SubtitleEdit.Forms private static string GetWholeWord(string text, int index) { int start = index; - while (start > 0 && (Environment.NewLine + " ,.!?\"'=()/-").Contains(text[start - 1].ToString()) == false) + while (start > 0 && !(Environment.NewLine + @" ,.!?""'=()/-").Contains(text[start - 1])) start--; int end = index; - while (end + 1 < text.Length && (Environment.NewLine + " ,.!?\"'=()/-").Contains(text[end + 1].ToString()) == false) + while (end + 1 < text.Length && !(Environment.NewLine + @" ,.!?""'=()/-").Contains(text[end + 1])) end++; return text.Substring(start, end - start + 1); @@ -1878,21 +1876,17 @@ namespace Nikse.SubtitleEdit.Forms Match match = ReAfterLowercaseLetter.Match(p.Text); while (match.Success) { - if (!(match.Index > 1 && p.Text.Substring(match.Index - 1, 2) == "Mc")) // irish names, McDonalds etc. + if (!(match.Index > 1 && p.Text.Substring(match.Index - 1, 2) == "Mc") // irish names, McDonalds etc. + && p.Text[match.Index + 1] == 'I' + && AllowFix(p, fixAction)) { - if (p.Text[match.Index + 1] == 'I') - { - if (AllowFix(p, fixAction)) - { - p.Text = p.Text.Substring(0, match.Index + 1) + "l"; - if (match.Index + 2 < oldText.Length) - p.Text += oldText.Substring(match.Index + 2); + p.Text = p.Text.Substring(0, match.Index + 1) + "l"; + if (match.Index + 2 < oldText.Length) + p.Text += oldText.Substring(match.Index + 2); - uppercaseIsInsideLowercaseWords++; - _totalFixes++; - AddFixToListView(p, fixAction, oldText, p.Text); - } - } + uppercaseIsInsideLowercaseWords++; + _totalFixes++; + AddFixToListView(p, fixAction, oldText, p.Text); } match = match.NextMatch(); } @@ -1928,37 +1922,26 @@ namespace Nikse.SubtitleEdit.Forms { if (match.Index > 2 && st.StrippedText[match.Index - 1] == ' ') { - if ((Utilities.AllLettersAndNumbers + ",").Contains(st.StrippedText[match.Index - 2].ToString())) + if ((Utilities.AllLettersAndNumbers + @",").Contains(st.StrippedText[match.Index - 2]) + && match.Length >= 2 && Utilities.LowerCaseVowels.Contains(char.ToLower(match.Value[1]))) { - string secondLetter = string.Empty; - if (match.Length >= 2) - secondLetter = match.Value.Substring(1, 1); - if (Utilities.LowerCaseVowels.Contains(secondLetter.ToLower())) - { - st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); - p.Text = st.MergedString; - uppercaseIsInsideLowercaseWords++; - _totalFixes++; - AddFixToListView(p, fixAction, oldText, p.Text); - } + st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); + p.Text = st.MergedString; + uppercaseIsInsideLowercaseWords++; + _totalFixes++; + AddFixToListView(p, fixAction, oldText, p.Text); } } - else if (match.Index > Environment.NewLine.Length + 1 && Environment.NewLine.Contains(st.StrippedText[match.Index - 1].ToString())) + else if (match.Index > Environment.NewLine.Length + 1 && Environment.NewLine.Contains(st.StrippedText[match.Index - 1])) { - if ((Utilities.AllLettersAndNumbers + ",").Contains(st.StrippedText[match.Index - (Environment.NewLine.Length + 1)].ToString())) + if ((Utilities.AllLettersAndNumbers + @",").Contains(st.StrippedText[match.Index - Environment.NewLine.Length + 1]) + && match.Length >= 2 && Utilities.LowerCaseVowels.Contains(match.Value[1])) { - string next = string.Empty; - if (match.Length >= 2) - next = match.Value.Substring(1, 1); - - if (Utilities.LowerCaseVowels.Contains(next)) - { - st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); - p.Text = st.MergedString; - uppercaseIsInsideLowercaseWords++; - _totalFixes++; - AddFixToListView(p, fixAction, oldText, p.Text); - } + st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); + p.Text = st.MergedString; + uppercaseIsInsideLowercaseWords++; + _totalFixes++; + AddFixToListView(p, fixAction, oldText, p.Text); } } else if (match.Index > 1 && ((st.StrippedText[match.Index - 1] == '\"') || (st.StrippedText[match.Index - 1] == '\'') || @@ -1967,14 +1950,14 @@ namespace Nikse.SubtitleEdit.Forms } else { - string before = string.Empty; - string after = string.Empty; + var before = '\0'; + var after = '\0'; if (match.Index > 0) - before = st.StrippedText.Substring(match.Index - 1, 1); + before = st.StrippedText[match.Index - 1]; if (match.Index < st.StrippedText.Length - 2) - after = st.StrippedText.Substring(match.Index + 1, 1); - if (before.Length == 1 && before != before.ToLower() && after.Length == 1 && after != after.ToUpper() && - !Utilities.LowerCaseVowels.Contains(before.ToLower()) && !Utilities.LowerCaseVowels.Contains(after.ToLower())) + after = st.StrippedText[match.Index + 1]; + if (before != '\0' && char.IsUpper(before) && after != '\0' && char.IsLower(after) && + !Utilities.LowerCaseVowels.Contains(char.ToLower(before)) && !Utilities.LowerCaseVowels.Contains(after)) { st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "i"); p.Text = st.MergedString; @@ -1982,19 +1965,16 @@ namespace Nikse.SubtitleEdit.Forms _totalFixes++; AddFixToListView(p, fixAction, oldText, p.Text); } + else if (@"‘’¡¿„“()[]♪'. ".Contains(before) && !Utilities.LowerCaseVowels.Contains(char.ToLower(after))) + { + } else { - if ("‘’¡¿„“()[]♪'. ".Contains(before) && !(Utilities.LowerCaseVowels).Contains(after.ToLower())) - { - } - else - { - st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); - p.Text = st.MergedString; - uppercaseIsInsideLowercaseWords++; - _totalFixes++; - AddFixToListView(p, fixAction, oldText, p.Text); - } + st.StrippedText = st.StrippedText.Remove(match.Index, 1).Insert(match.Index, "l"); + p.Text = st.MergedString; + uppercaseIsInsideLowercaseWords++; + _totalFixes++; + AddFixToListView(p, fixAction, oldText, p.Text); } } } @@ -2053,12 +2033,12 @@ namespace Nikse.SubtitleEdit.Forms } else if (!string.IsNullOrEmpty(nextText) && next != null && next.Text.Length > 0 && - Utilities.UppercaseLetters.Contains(nextText[0].ToString()) && + Utilities.UppercaseLetters.Contains(nextText[0]) && tempNoHtml.Length > 0 && - (!",.!?:;>-])♪♫…".Contains(tempNoHtml[tempNoHtml.Length - 1].ToString()))) + !@",.!?:;>-])♪♫…".Contains(tempNoHtml[tempNoHtml.Length - 1])) { string tempTrimmed = tempNoHtml.TrimEnd().TrimEnd('\'', '"', '“', '”').TrimEnd(); - if (tempTrimmed.Length > 0 && !")]*#¶.!?".Contains(tempTrimmed.Substring(tempTrimmed.Length - 1))) + if (tempTrimmed.Length > 0 && !@")]*#¶.!?".Contains(tempTrimmed[tempTrimmed.Length - 1])) { if (p.Text != p.Text.ToUpper()) { @@ -2098,18 +2078,18 @@ namespace Nikse.SubtitleEdit.Forms } } } - else if (next != null && !string.IsNullOrEmpty(p.Text) && Utilities.AllLettersAndNumbers.Contains(p.Text[p.Text.Length - 1].ToString())) + else if (next != null && !string.IsNullOrEmpty(p.Text) && Utilities.AllLettersAndNumbers.Contains(p.Text[p.Text.Length - 1])) { if (p.Text != p.Text.ToUpper()) { StripableText st = new StripableText(next.Text); if (st.StrippedText.Length > 0 && st.StrippedText != st.StrippedText.ToUpper() && - Utilities.UppercaseLetters.Contains(st.StrippedText[0].ToString())) + Utilities.UppercaseLetters.Contains(st.StrippedText[0])) { if (AllowFix(p, fixAction)) { int j = p.Text.Length - 1; - while (j >= 0 && !(".!?¿¡").Contains(p.Text[j].ToString())) + while (j >= 0 && !@".!?¿¡".Contains(p.Text[j])) j--; string endSign = "."; if (j >= 0 && p.Text[j] == '¿') @@ -2138,7 +2118,7 @@ namespace Nikse.SubtitleEdit.Forms indexOfNewLine = p.Text.IndexOf(Environment.NewLine + " -", 3, StringComparison.Ordinal); if (indexOfNewLine > 0) { - if (Configuration.Settings.General.UppercaseLetters.Contains(p.Text[indexOfNewLine - 1].ToString().ToUpper())) + if (Configuration.Settings.General.UppercaseLetters.Contains(char.ToUpper(p.Text[indexOfNewLine - 1]))) { if (AllowFix(p, fixAction)) { @@ -2299,8 +2279,7 @@ namespace Nikse.SubtitleEdit.Forms text = text.Substring(1); } - string oldText = p.Text; - string firstLetter = text.Substring(0, 1); + var firstLetter = text[0]; string prevText = " ."; if (prev != null) @@ -2310,8 +2289,8 @@ namespace Nikse.SubtitleEdit.Forms if (prevText == " .") isPrevEndOfLine = true; if ((!text.StartsWith("www.") && !text.StartsWith("http:") && !text.StartsWith("https:")) && - (firstLetter != firstLetter.ToUpper() || IsTurkishLittleI(firstLetter, encoding, language)) && - !"0123456789".Contains(firstLetter) && + (char.IsLower(firstLetter) || IsTurkishLittleI(firstLetter, encoding, language)) && + !char.IsDigit(firstLetter) && isPrevEndOfLine) { bool isMatchInKnowAbbreviations = language == "en" && @@ -2328,7 +2307,7 @@ namespace Nikse.SubtitleEdit.Forms text.StartsWith("ls") || text.StartsWith("lt") || text.StartsWith("lf ") || text.StartsWith("lc") || text.StartsWith("l'm ")) || text.StartsWith("l am ")) // l > I p.Text = pre + "I" + text.Substring(1); else - p.Text = pre + firstLetter.ToUpper() + text.Substring(1); + p.Text = pre + char.ToUpper(firstLetter) + text.Substring(1); } } } @@ -2381,12 +2360,11 @@ namespace Nikse.SubtitleEdit.Forms text = text.Substring(1); } - string oldText = p.Text; - string firstLetter = text.Substring(0, 1); + char firstLetter = text[0]; string prevText = Utilities.RemoveHtmlTags(arr[0]); bool isPrevEndOfLine = IsPrevoiusTextEndOfParagraph(prevText); if ((!text.StartsWith("www.") && !text.StartsWith("http:") && !text.StartsWith("https:")) && - (firstLetter != firstLetter.ToUpper() || IsTurkishLittleI(firstLetter, encoding, language)) && + (char.IsLower(firstLetter) || IsTurkishLittleI(firstLetter, encoding, language)) && !prevText.EndsWith("...", StringComparison.Ordinal) && isPrevEndOfLine) { @@ -2404,7 +2382,7 @@ namespace Nikse.SubtitleEdit.Forms text.StartsWith("ls") || text.StartsWith("lt") || text.StartsWith("lf ") || text.StartsWith("lc") || text.StartsWith("l'm ")) || text.StartsWith("l am ")) // l > I text = pre + "I" + text.Substring(1); else - text = pre + firstLetter.ToUpper() + text.Substring(1); + text = pre + char.ToUpper(firstLetter) + text.Substring(1); p.Text = arr[0] + Environment.NewLine + text; } } @@ -2417,11 +2395,11 @@ namespace Nikse.SubtitleEdit.Forms { if (isPrevEndOfLine && arr[1].StartsWith("- ") && arr[1].Length > 6) { - p.Text = arr[0] + Environment.NewLine + "- " + arr[1].Substring(5, 1).ToUpper() + arr[1].Remove(0, 6); + p.Text = arr[0] + Environment.NewLine + "- " + char.ToUpper(arr[1][5]) + arr[1].Remove(0, 6); } else if (isPrevEndOfLine && arr[1].StartsWith("- ") && arr[1].Length > 3) { - p.Text = arr[0] + Environment.NewLine + "- " + arr[1].Substring(2, 1).ToUpper() + arr[1].Remove(0, 3); + p.Text = arr[0] + Environment.NewLine + "- " + char.ToUpper(arr[1][2]) + arr[1].Remove(0, 3); } arr = p.Text.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n'); @@ -2433,11 +2411,11 @@ namespace Nikse.SubtitleEdit.Forms isPrevEndOfLine = true; if (isPrevLineEndOfLine && arr[0].StartsWith("- ") && arr[0].Length > 6) { - p.Text = "- " + arr[0].Substring(5, 1).ToUpper() + arr[0].Remove(0, 6) + Environment.NewLine + arr[1]; + p.Text = "- " + char.ToUpper(arr[0][5]) + arr[0].Remove(0, 6) + Environment.NewLine + arr[1]; } else if (isPrevLineEndOfLine && arr[0].StartsWith("- ") && arr[0].Length > 3) { - p.Text = "- " + arr[0].Substring(2, 1).ToUpper() + arr[0].Remove(0, 3) + Environment.NewLine + arr[1]; + p.Text = "- " + char.ToUpper(arr[0][2]) + arr[0].Remove(0, 3) + Environment.NewLine + arr[1]; } } @@ -2489,14 +2467,14 @@ 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[0], encoding, language) && !st.Pre.EndsWith('[') && !st.Pre.Contains("...")) { - text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, GetTurkishUppercaseLetter(st.StrippedText, encoding)) + st.Post; + text = st.Pre + GetTurkishUppercaseLetter(st.StrippedText[0], encoding) + st.StrippedText.Substring(1) + 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("...")) { - text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, st.StrippedText[0].ToString().ToUpper()) + st.Post; + text = st.Pre + char.ToUpper(st.StrippedText[0]) + st.StrippedText.Substring(1) + st.Post; p.Text = p.Text.Remove(indexOfNewLine + len).Insert(indexOfNewLine + len, text); } } @@ -2504,31 +2482,35 @@ namespace Nikse.SubtitleEdit.Forms return p.Text; } - private static bool IsTurkishLittleI(string firstLetter, Encoding encoding, string language) + private static bool IsTurkishLittleI(char firstLetter, Encoding encoding, string language) { - if (encoding == Encoding.UTF8) - return language == "tr" && (firstLetter.StartsWith('ı') || firstLetter.StartsWith('i')); - else - return language == "tr" && (firstLetter.StartsWith('ý') || firstLetter.StartsWith('i')); + if (language != "tr") + { + return false; + } + + return encoding.Equals(Encoding.UTF8) + ? firstLetter == 'ı' || firstLetter == 'i' + : firstLetter == 'ý' || firstLetter == 'i'; } - private static string GetTurkishUppercaseLetter(string s, Encoding encoding) + private static char GetTurkishUppercaseLetter(char letter, Encoding encoding) { - if (encoding == Encoding.UTF8) + if (encoding.Equals(Encoding.UTF8)) { - if (s.StartsWith('ı')) - return "I"; - else if (s.StartsWith('i')) - return "İ"; + if (letter == 'ı') + return 'I'; + if (letter == 'i') + return 'İ'; } else { - if (s.StartsWith('i')) - return "Ý"; - else if (s.StartsWith('ý')) - return "I"; + if (letter == 'i') + return 'Ý'; + if (letter == 'ý') + return 'I'; } - return s.Substring(0, 1); + return letter; } private static bool IsPrevoiusTextEndOfParagraph(string prevText) @@ -2545,7 +2527,7 @@ namespace Nikse.SubtitleEdit.Forms if (isPrevEndOfLine && prevText.Length > 5 && prevText.EndsWith('.') && prevText[prevText.Length - 3] == '.' && - Utilities.AllLetters.Contains(prevText[prevText.Length - 2].ToString())) + Utilities.AllLetters.Contains(prevText[prevText.Length - 2])) isPrevEndOfLine = false; return isPrevEndOfLine; } @@ -2565,7 +2547,7 @@ namespace Nikse.SubtitleEdit.Forms int start = text.IndexOfAny(new[] { '.', '!', '?' }); while (start != -1 && start < text.Length) { - if (start > 0 && Utilities.IsInteger(text[start - 1].ToString())) + if (start > 0 && char.IsDigit(text[start - 1])) { // ignore periods after a number } @@ -2574,22 +2556,22 @@ namespace Nikse.SubtitleEdit.Forms if (!IsAbbreviation(text, start)) { StripableText subText = new StripableText(text.Substring(start + 2)); - if (subText.StrippedText.Length > 0 && IsTurkishLittleI(subText.StrippedText, _encoding, Language)) + if (subText.StrippedText.Length > 0 && IsTurkishLittleI(subText.StrippedText[0], _encoding, Language)) { if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains('\'') && subText.StrippedText.StartsWith('s'))) { - text = text.Substring(0, start + 2) + subText.Pre + GetTurkishUppercaseLetter(subText.StrippedText, _encoding) + subText.StrippedText.Substring(1) + subText.Post; + text = text.Substring(0, start + 2) + subText.Pre + GetTurkishUppercaseLetter(subText.StrippedText[0], _encoding) + subText.StrippedText.Substring(1) + subText.Post; if (AllowFix(p, fixAction)) { p.Text = st.Pre + text + st.Post; } } } - else if (subText.StrippedText.Length > 0 && Configuration.Settings.General.UppercaseLetters.Contains(subText.StrippedText[0].ToString(), StringComparison.OrdinalIgnoreCase)) + else if (subText.StrippedText.Length > 0 && Configuration.Settings.General.UppercaseLetters.Contains(char.ToUpper(subText.StrippedText[0]))) { if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains('\'') && subText.StrippedText.StartsWith('s'))) { - text = text.Substring(0, start + 2) + subText.Pre + subText.StrippedText[0].ToString().ToUpper() + subText.StrippedText.Substring(1) + subText.Post; + text = text.Substring(0, start + 2) + subText.Pre + char.ToUpper(subText.StrippedText[0]) + subText.StrippedText.Substring(1) + subText.Post; if (AllowFix(p, fixAction)) { p.Text = st.Pre + text + st.Post; @@ -2643,8 +2625,8 @@ namespace Nikse.SubtitleEdit.Forms bool lastWasColon = false; for (int j = 0; j < p.Text.Length; j++) { - string s = p.Text[j].ToString(); - if (s == ":" || s == ";") + var s = p.Text[j]; + if (s == ':' || s == ';') { lastWasColon = true; } @@ -2659,15 +2641,15 @@ namespace Nikse.SubtitleEdit.Forms else if (p.Text.Substring(j).StartsWith("")) skipCount = 2; else if (p.Text.Substring(j).StartsWith("')) - skipCount = p.Text.Substring(j).IndexOf(">", StringComparison.Ordinal) - p.Text.Substring(j).IndexOf("') - p.Text.Substring(j).IndexOf(" 0 && Utilities.AllLettersAndNumbers.Contains(text[index - 1].ToString()) && text[index - 2] == '.') // e.g: O.R. + if (index - 3 > 0 && Utilities.AllLettersAndNumbers.Contains(text[index - 1]) && text[index - 2] == '.') // e.g: O.R. return true; string word = string.Empty; int i = index - 1; - while (i >= 0 && Utilities.AllLetters.Contains(text[i].ToString())) + while (i >= 0 && Utilities.AllLetters.Contains(text[i])) { - word = text[i].ToString() + word; + word = text[i] + word; i--; } @@ -2794,11 +2776,11 @@ namespace Nikse.SubtitleEdit.Forms { string part0 = Utilities.RemoveHtmlTags(parts[0]).Trim(); string part1 = Utilities.RemoveHtmlTags(parts[1]).Trim(); - if (part0.Length > 1 && "!?.".Contains(part0.Substring(part0.Length - 1, 1)) && - part1.Length > 1 && ("'" + Utilities.UppercaseLetters).Contains(part1.Substring(0, 1))) + if (part0.Length > 1 && @"!?.".Contains(part0[part0.Length - 1]) && + part1.Length > 1 && ("'" + Utilities.UppercaseLetters).Contains(part1[0])) { text = text.Replace(" - ", Environment.NewLine + "- "); - if (Utilities.AllLettersAndNumbers.Contains(part0.Substring(0, 1))) + if (Utilities.AllLettersAndNumbers.Contains(part0[0])) { if (text.StartsWith("")) text = "- " + text; @@ -2936,31 +2918,31 @@ namespace Nikse.SubtitleEdit.Forms { if (s[match.Index] == target) { - string prev = string.Empty; - string next = string.Empty; + var prev = '\0'; + var next = '\0'; if (match.Index > 0) - prev = s[match.Index - 1].ToString(); + prev = s[match.Index - 1]; if (match.Index + 1 < s.Length) - next = s[match.Index + 1].ToString(); + next = s[match.Index + 1]; string wholePrev = string.Empty; if (match.Index > 1) wholePrev = s.Substring(0, match.Index - 1); - if (prev != ">" && next != ">" && next != "}" && !wholePrev.TrimEnd().EndsWith("...", StringComparison.Ordinal)) + if (prev != '>' && next != '>' && next != '}' && !wholePrev.TrimEnd().EndsWith("...", StringComparison.Ordinal)) { bool fix = true; - if (prev == "." || prev == "'") + if (prev == '.' || prev == '\'') fix = false; - if (prev == " " && next == ".") + if (prev == ' ' && next == '.') fix = false; - if (prev == "-" && match.Index > 2) + if (prev == '-' && match.Index > 2) fix = false; - if (fix && next == "-" && match.Index < s.Length - 5 && s[match.Index + 2] == 'l' && !(Environment.NewLine + " <>!.?:;,").Contains(s[match.Index + 3].ToString())) + if (fix && next == '-' && match.Index < s.Length - 5 && s[match.Index + 2] == 'l' && !(Environment.NewLine + @" <>!.?:;,").Contains(s[match.Index + 3])) fix = false; if (fix) @@ -3163,7 +3145,7 @@ namespace Nikse.SubtitleEdit.Forms { int idx = text.IndexOf('-'); bool addFirstLine = idx < 5; - if (addFirstLine && idx > 0 && Utilities.AllLetters.Contains(text.Substring(idx - 1, 1))) + if (addFirstLine && idx > 0 && Utilities.AllLetters.Contains(text[idx - 1])) addFirstLine = false; if (addFirstLine) { @@ -3434,7 +3416,7 @@ namespace Nikse.SubtitleEdit.Forms if (text.Length > 1 && text.StartsWith('-')) { pre += "- "; - if (text.Substring(1, 1) == " ") + if (text[1] == ' ') text = text.Substring(2); else text = text.Substring(1); @@ -3442,16 +3424,16 @@ namespace Nikse.SubtitleEdit.Forms if (text.Length > 3 && text.StartsWith("")) { pre += ""; - if (text.Substring(3, 1) == " ") + if (text[3] == ' ') text = text.Substring(4); else text = text.Substring(3); } if (text.Length > 1 && (text[0] == ' ' || text[0] == '.')) { - pre += (text[0] == '.' ? '.' : ' ').ToString(); + pre += text[0] == '.' ? '.' : ' '; text = text.Substring(1); - while (text.Length > 0 && text.Substring(0, 1) == ".") + while (text.Length > 0 && text[0] == '.') { pre += "."; text = text.Substring(1); @@ -4208,8 +4190,8 @@ namespace Nikse.SubtitleEdit.Forms string oldText = p.Text; - FixSpanishInvertedLetter("?", "¿", p, last, ref wasLastLineClosed, fixAction, ref fixCount); - FixSpanishInvertedLetter("!", "¡", p, last, ref wasLastLineClosed, fixAction, ref fixCount); + FixSpanishInvertedLetter('?', "¿", p, last, ref wasLastLineClosed, fixAction, ref fixCount); + FixSpanishInvertedLetter('!', "¡", p, last, ref wasLastLineClosed, fixAction, ref fixCount); if (p.Text != oldText) { @@ -4223,7 +4205,7 @@ namespace Nikse.SubtitleEdit.Forms LogStatus(_language.FixSpanishInvertedQuestionAndExclamationMarks, fixCount.ToString()); } - private void FixSpanishInvertedLetter(string mark, string inverseMark, Paragraph p, Paragraph last, ref bool wasLastLineClosed, string fixAction, ref int fixCount) + private void FixSpanishInvertedLetter(char mark, string inverseMark, Paragraph p, Paragraph last, ref bool wasLastLineClosed, string fixAction, ref int fixCount) { if (p.Text.Contains(mark)) { @@ -4233,7 +4215,7 @@ namespace Nikse.SubtitleEdit.Forms if (!skip && Utilities.CountTagInText(p.Text, mark) == Utilities.CountTagInText(p.Text, inverseMark) && Utilities.RemoveHtmlTags(p.Text).TrimStart(inverseMark[0]).Contains(inverseMark) == false && - Utilities.RemoveHtmlTags(p.Text).TrimEnd(mark[0]).Contains(mark) == false) + Utilities.RemoveHtmlTags(p.Text).TrimEnd(mark).Contains(mark) == false) { skip = true; } @@ -4241,7 +4223,7 @@ namespace Nikse.SubtitleEdit.Forms if (!skip) { int startIndex = 0; - int markIndex = p.Text.IndexOf(mark, StringComparison.Ordinal); + int markIndex = p.Text.IndexOf(mark); if (!wasLastLineClosed && ((p.Text.IndexOf("!", StringComparison.Ordinal) > 0 && p.Text.IndexOf("!", StringComparison.Ordinal) < markIndex) || (p.Text.IndexOf("?", StringComparison.Ordinal) > 0 && p.Text.IndexOf("?", StringComparison.Ordinal) < markIndex) || (p.Text.IndexOf(".", StringComparison.Ordinal) > 0 && p.Text.IndexOf(".", StringComparison.Ordinal) < markIndex))) @@ -4267,7 +4249,7 @@ namespace Nikse.SubtitleEdit.Forms !(j > 6 && p.Text.Substring(j - 6, 6) == Environment.NewLine + "-")) j--; - if (".!?".Contains(p.Text[j].ToString())) + if (@".!?".Contains(p.Text[j])) { j++; } @@ -4285,28 +4267,28 @@ namespace Nikse.SubtitleEdit.Forms string speaker = string.Empty; int speakerEnd = part.IndexOf(")", StringComparison.Ordinal); - if (part.StartsWith('(') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark, StringComparison.Ordinal)) + if (part.StartsWith('(') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark)) { - while (Environment.NewLine.Contains(part[speakerEnd + 1].ToString())) + while (Environment.NewLine.Contains(part[speakerEnd + 1])) speakerEnd++; speaker = part.Substring(0, speakerEnd + 1); part = part.Substring(speakerEnd + 1); } speakerEnd = part.IndexOf(']'); - if (part.StartsWith('[') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark, StringComparison.Ordinal)) + if (part.StartsWith('[') && speakerEnd > 0 && speakerEnd < part.IndexOf(mark)) { - while (Environment.NewLine.Contains(part[speakerEnd + 1].ToString())) + while (Environment.NewLine.Contains(part[speakerEnd + 1])) speakerEnd++; speaker = part.Substring(0, speakerEnd + 1); part = part.Substring(speakerEnd + 1); } var st = new StripableText(part); - if (j == 0 && mark == "!" && st.Pre == "¿" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark, StringComparison.Ordinal)) + if (j == 0 && mark == '!' && st.Pre == "¿" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark)) { p.Text = inverseMark + p.Text; } - else if (j == 0 && mark == "?" && st.Pre == "¡" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark, StringComparison.Ordinal)) + else if (j == 0 && mark == '?' && st.Pre == "¡" && Utilities.CountTagInText(p.Text, mark) == 1 && Utilities.RemoveHtmlTags(p.Text).EndsWith(mark)) { p.Text = inverseMark + p.Text; } @@ -4314,7 +4296,7 @@ namespace Nikse.SubtitleEdit.Forms { string temp = inverseMark; int addToIndex = 0; - while (p.Text.Length > markIndex + 1 && p.Text[markIndex + 1].ToString() == mark && + while (p.Text.Length > markIndex + 1 && p.Text[markIndex + 1] == mark && Utilities.CountTagInText(p.Text, mark) > Utilities.CountTagInText(p.Text + temp, inverseMark)) { temp += inverseMark; @@ -4330,7 +4312,7 @@ namespace Nikse.SubtitleEdit.Forms } } } - else if (last != null && !wasLastLineClosed && inverseMarkIndex == p.Text.IndexOf(mark, StringComparison.Ordinal) && !last.Text.Contains(inverseMark)) + else if (last != null && !wasLastLineClosed && inverseMarkIndex == p.Text.IndexOf(mark) && !last.Text.Contains(inverseMark)) { string lastOldtext = last.Text; int idx = last.Text.Length - 2; @@ -4345,7 +4327,7 @@ namespace Nikse.SubtitleEdit.Forms startIndex = markIndex + 2; if (startIndex < p.Text.Length) - markIndex = p.Text.IndexOf(mark, startIndex, StringComparison.Ordinal); + markIndex = p.Text.IndexOf(mark, startIndex); else markIndex = -1; wasLastLineClosed = true; @@ -4359,13 +4341,13 @@ namespace Nikse.SubtitleEdit.Forms else if (Utilities.CountTagInText(p.Text, inverseMark) == 1) { int idx = p.Text.IndexOf(inverseMark, StringComparison.Ordinal); - while (idx < p.Text.Length && !".!?".Contains(p.Text[idx].ToString())) + while (idx < p.Text.Length && !@".!?".Contains(p.Text[idx])) { idx++; } if (idx < p.Text.Length) { - p.Text = p.Text.Insert(idx, mark); + p.Text = p.Text.Insert(idx, mark.ToString()); if (p.Text.Contains("¡¿") && p.Text.Contains("!?")) p.Text.Replace("!?", "?!"); if (p.Text.Contains("¿¡") && p.Text.Contains("?!")) @@ -4387,9 +4369,9 @@ namespace Nikse.SubtitleEdit.Forms string word = string.Empty; int i = index - 1; - while (i >= 0 && Utilities.AllLetters.Contains(text[i].ToString())) + while (i >= 0 && Utilities.AllLetters.Contains(text[i])) { - word = text[i].ToString() + word; + word = text[i] + word; i--; } @@ -4620,12 +4602,12 @@ namespace Nikse.SubtitleEdit.Forms { startCharactersOk++; - if (before.Substring(i, 1).Trim().Length == 0) + if (char.IsWhiteSpace(before[i])) beforeBackgroundColors.Add(i, Color.Red); else beforeColors.Add(i, Color.Red); - if (after.Substring(i, 1).Trim().Length == 0) + if (char.IsWhiteSpace(after[i])) afterBackgroundColors.Add(i, Color.Red); else afterColors.Add(i, Color.Red); @@ -4642,14 +4624,14 @@ namespace Nikse.SubtitleEdit.Forms { if (i < before.Length) { - if (before.Substring(i, 1).Trim().Length == 0) + if (char.IsWhiteSpace(before[i])) beforeBackgroundColors.Add(i, Color.Red); else beforeColors.Add(i, Color.Red); } if (i < after.Length) { - if (after.Substring(i, 1).Trim().Length == 0) + if (char.IsWhiteSpace(after[i])) afterBackgroundColors.Add(i, Color.Red); else afterColors.Add(i, Color.Red); @@ -4693,7 +4675,7 @@ namespace Nikse.SubtitleEdit.Forms var sb = new StringBuilder(); for (int i = 0; i < before.Length; i++) { - string s = before.Substring(i, 1); + var s = before[i]; if (beforeColors.ContainsKey(i) && beforeBackgroundColors.ContainsKey(i)) { sb.AppendFormat("{2}", ColorTranslator.ToHtml(beforeColors[i]), ColorTranslator.ToHtml(beforeBackgroundColors[i]), s); @@ -4708,13 +4690,13 @@ namespace Nikse.SubtitleEdit.Forms } else { - sb.Append(before.Substring(i, 1)); + sb.Append(s); } } var sb2 = new StringBuilder(); for (int i = 0; i < after.Length; i++) { - string s = after.Substring(i, 1); + var s = after[i]; if (afterColors.ContainsKey(i) && afterBackgroundColors.ContainsKey(i)) { sb2.AppendFormat("{2}", ColorTranslator.ToHtml(afterColors[i]), ColorTranslator.ToHtml(afterBackgroundColors[i]), s); diff --git a/src/Forms/GoogleTranslate.cs b/src/Forms/GoogleTranslate.cs index 5d7e8cc2c..b9e2891fe 100644 --- a/src/Forms/GoogleTranslate.cs +++ b/src/Forms/GoogleTranslate.cs @@ -37,7 +37,7 @@ namespace Nikse.SubtitleEdit.Forms public ComboBoxItem(string text, string value) { if (text.Length > 1) - text = text.Substring(0, 1).ToUpper() + text.Substring(1).ToLower(); + text = char.ToUpper(text[0]) + text.Substring(1).ToLower(); Text = text; Value = value; @@ -253,7 +253,7 @@ namespace Nikse.SubtitleEdit.Forms if (indexOfP >= 0 && indexOfP < 4) cleanText = cleanText.Remove(0, cleanText.IndexOf(_splitterString.Trim(), StringComparison.Ordinal)); cleanText = cleanText.Replace(_splitterString.Trim(), string.Empty).Trim(); - if (cleanText.Contains("\n") && !cleanText.Contains("\r")) + if (cleanText.Contains('\n') && !cleanText.Contains('\r')) cleanText = cleanText.Replace("\n", Environment.NewLine); cleanText = cleanText.Replace(" ...", "..."); cleanText = cleanText.Replace(_newlineString.Trim(), Environment.NewLine); diff --git a/src/Forms/HardSubExtract.cs b/src/Forms/HardSubExtract.cs index cf4d8c926..f53fc485b 100644 --- a/src/Forms/HardSubExtract.cs +++ b/src/Forms/HardSubExtract.cs @@ -239,7 +239,7 @@ namespace Nikse.SubtitleEdit.Forms { try { - var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".bmp"); + var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".bmp"); _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); System.Threading.Thread.Sleep(100); if (File.Exists(fileName)) diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index e9a2e6c7a..06b2ca11d 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -475,7 +475,7 @@ namespace Nikse.SubtitleEdit.Forms for (double zoomCounter = AudioVisualizer.ZoomMininum; zoomCounter <= AudioVisualizer.ZoomMaxinum + (0.001); zoomCounter += 0.1) { int percent = (int)Math.Round((zoomCounter * 100)); - ComboBoxZoomItem item = new ComboBoxZoomItem() { Text = percent.ToString() + "%", ZoomFactor = zoomCounter }; + ComboBoxZoomItem item = new ComboBoxZoomItem() { Text = percent + "%", ZoomFactor = zoomCounter }; toolStripComboBoxWaveForm.Items.Add(item); if (percent == 100) toolStripComboBoxWaveForm.SelectedIndex = toolStripComboBoxWaveForm.Items.Count - 1; @@ -1137,7 +1137,7 @@ namespace Nikse.SubtitleEdit.Forms if (!string.IsNullOrEmpty(outputFolder)) outputFileName = Path.Combine(outputFolder, Path.GetFileName(outputFileName)); if (File.Exists(outputFileName) && !overwrite) - outputFileName = Path.ChangeExtension(outputFileName, Guid.NewGuid().ToString() + extension); + outputFileName = Path.ChangeExtension(outputFileName, Guid.NewGuid() + extension); return outputFileName; } @@ -3888,17 +3888,17 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.General.SubtitleFontBold + Configuration.Settings.General.CenterSubtitleInTextBox + Configuration.Settings.General.SubtitleFontSize + - Configuration.Settings.General.SubtitleFontColor.ToArgb().ToString() + - Configuration.Settings.General.SubtitleBackgroundColor.ToArgb().ToString(); + Configuration.Settings.General.SubtitleFontColor.ToArgb() + + Configuration.Settings.General.SubtitleBackgroundColor.ToArgb(); bool oldUseTimeFormatHHMMSSFF = Configuration.Settings.General.UseTimeFormatHHMMSSFF; string oldSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorDurationBig.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorLongLines.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorOverlap.ToString() + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines.ToString() + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX.ToString() + - Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb().ToString(); + Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + + Configuration.Settings.Tools.ListViewSyntaxColorLongLines + + Configuration.Settings.Tools.ListViewSyntaxColorOverlap + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX + + Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); var oldAllowEditOfOriginalSubtitle = Configuration.Settings.General.AllowEditOfOriginalSubtitle; var settings = new Settings(); @@ -3938,19 +3938,19 @@ namespace Nikse.SubtitleEdit.Forms audioVisualizer.ClosenessForBorderSelection = Configuration.Settings.VideoControls.WaveformBorderHitMs; string newSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorDurationBig.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorLongLines.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorOverlap.ToString() + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines.ToString() + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX.ToString() + - Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb().ToString(); + Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + + Configuration.Settings.Tools.ListViewSyntaxColorLongLines + + Configuration.Settings.Tools.ListViewSyntaxColorOverlap + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX + + Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); if (oldSubtitleFontSettings != Configuration.Settings.General.SubtitleFontName + Configuration.Settings.General.SubtitleFontBold + Configuration.Settings.General.CenterSubtitleInTextBox + Configuration.Settings.General.SubtitleFontSize + - Configuration.Settings.General.SubtitleFontColor.ToArgb().ToString() + - Configuration.Settings.General.SubtitleBackgroundColor.ToArgb().ToString() || + Configuration.Settings.General.SubtitleFontColor.ToArgb() + + Configuration.Settings.General.SubtitleBackgroundColor.ToArgb() || oldSyntaxColoring != newSyntaxColoring) { try @@ -5820,7 +5820,7 @@ namespace Nikse.SubtitleEdit.Forms Paragraph p = _subtitle.Paragraphs[index]; int errorsBefore; int errorsAfter; - ShowStatus(string.Format(_language.SpellChekingViaWordXLineYOfX, version, index + 1, _subtitle.Paragraphs.Count.ToString())); + ShowStatus(string.Format(_language.SpellChekingViaWordXLineYOfX, version, index + 1, _subtitle.Paragraphs.Count)); SubtitleListview1.SelectIndexAndEnsureVisible(index); string newText = wordSpellChecker.CheckSpelling(p.Text, out errorsBefore, out errorsAfter); if (errorsAfter > 0) @@ -5953,14 +5953,14 @@ namespace Nikse.SubtitleEdit.Forms while (startIndex >= 0 && startIndex < p.Text.Length && p.Text.Substring(startIndex).Contains(oldWord)) { bool startOk = startIndex == 0 || p.Text[startIndex - 1] == ' ' || startIndex == p.Text.Length - oldWord.Length || - Environment.NewLine.EndsWith(p.Text[startIndex - 1].ToString()); + Environment.NewLine.EndsWith(p.Text[startIndex - 1]); if (startOk) { int end = startIndex + oldWord.Length; if (end <= p.Text.Length) { - if ((end == p.Text.Length) || ((" ,.!?:;')" + Environment.NewLine).Contains(p.Text[end].ToString()))) + if (end == p.Text.Length || (@" ,.!?:;')" + Environment.NewLine).Contains(p.Text[end])) p.Text = p.Text.Remove(startIndex, oldWord.Length).Insert(startIndex, changeWord); } } @@ -8623,11 +8623,11 @@ namespace Nikse.SubtitleEdit.Forms private void SaveUndockedPositions() { if (_videoPlayerUnDocked != null && !_videoPlayerUnDocked.IsDisposed) - Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUnDocked.Left.ToString() + ";" + _videoPlayerUnDocked.Top.ToString() + ";" + _videoPlayerUnDocked.Width + ";" + _videoPlayerUnDocked.Height; + Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUnDocked.Left + @";" + _videoPlayerUnDocked.Top + @";" + _videoPlayerUnDocked.Width + @";" + _videoPlayerUnDocked.Height; if (_waveFormUnDocked != null && !_waveFormUnDocked.IsDisposed) - Configuration.Settings.General.UndockedWaveformPosition = _waveFormUnDocked.Left.ToString() + ";" + _waveFormUnDocked.Top.ToString() + ";" + _waveFormUnDocked.Width + ";" + _waveFormUnDocked.Height; + Configuration.Settings.General.UndockedWaveformPosition = _waveFormUnDocked.Left + @";" + _waveFormUnDocked.Top + @";" + _waveFormUnDocked.Width + @";" + _waveFormUnDocked.Height; if (_videoControlsUnDocked != null && !_videoControlsUnDocked.IsDisposed) - Configuration.Settings.General.UndockedVideoControlsPosition = _videoControlsUnDocked.Left.ToString() + ";" + _videoControlsUnDocked.Top.ToString() + ";" + _videoControlsUnDocked.Width + ";" + _videoControlsUnDocked.Height; + Configuration.Settings.General.UndockedVideoControlsPosition = _videoControlsUnDocked.Left + @";" + _videoControlsUnDocked.Top + @";" + _videoControlsUnDocked.Width + @";" + _videoControlsUnDocked.Height; } private void ButtonUnBreakClick(object sender, EventArgs e) @@ -8757,7 +8757,7 @@ namespace Nikse.SubtitleEdit.Forms if (lastTimeCode >= 0) { string tc = s.Substring(lastTimeCode).Trim(); - while (tc.Length > 0 && !Utilities.IsInteger(tc.Substring(0, 1))) + while (tc.Length > 0 && !char.IsDigit(tc[0])) tc = tc.Remove(0, 1); if (tc.Length > 12) { @@ -11594,7 +11594,7 @@ namespace Nikse.SubtitleEdit.Forms if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds + 100 > tc.TotalMilliseconds || offset > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) return; - MakeHistoryForUndo(_language.BeforeSetEndTimeAndOffsetTheRest + " " + _subtitle.Paragraphs[index].Number.ToString() + " - " + tc); + MakeHistoryForUndo(_language.BeforeSetEndTimeAndOffsetTheRest + @" " + _subtitle.Paragraphs[index].Number + @" - " + tc); numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; @@ -11785,15 +11785,15 @@ namespace Nikse.SubtitleEdit.Forms var post = new StringBuilder(); int i = 0; - while (i < s2.Length && "- !?.\"،,():;[]".Contains(s2[i].ToString())) + while (i < s2.Length && @"- !?.""،,():;[]".Contains(s2[i])) { - pre.Append(s2[i].ToString()); + pre.Append(s2[i]); i++; } int j = s2.Length - 1; - while (j > i && "- !?.\"،,():;[]".Contains(s2[j].ToString())) + while (j > i && @"- !?.""،,():;[]".Contains(s2[j])) { - post.Append(s2[j].ToString()); + post.Append(s2[j]); j--; } if (startsWithItalic) @@ -14483,7 +14483,7 @@ namespace Nikse.SubtitleEdit.Forms var tc = TimeCode.FromSeconds(videoPosition); timeUpDownStartTime.TimeCode = tc; - MakeHistoryForUndo(_language.BeforeSetStartTimeAndOffsetTheRest + " " + _subtitle.Paragraphs[index].Number.ToString() + " - " + tc); + MakeHistoryForUndo(_language.BeforeSetStartTimeAndOffsetTheRest + @" " + _subtitle.Paragraphs[index].Number + @" - " + tc); double offset = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds - tc.TotalMilliseconds; @@ -15020,7 +15020,7 @@ namespace Nikse.SubtitleEdit.Forms if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) { var item = new ToolStripMenuItem(); - item.Name = "Plugin" + toolsPluginCount.ToString(); + item.Name = "Plugin" + toolsPluginCount; item.Text = text; item.Tag = pluginFileName; @@ -15334,7 +15334,7 @@ namespace Nikse.SubtitleEdit.Forms Directory.CreateDirectory(dir); FileInfo fi = new FileInfo(videoFileName); - string wavePeakName = Sha256Hash(Path.GetFileName(videoFileName) + fi.Length.ToString() + fi.CreationTimeUtc.ToShortDateString()) + ".wav"; + string wavePeakName = Sha256Hash(Path.GetFileName(videoFileName) + fi.Length + fi.CreationTimeUtc.ToShortDateString()) + ".wav"; wavePeakName = wavePeakName.Replace("=", string.Empty).Replace("/", string.Empty).Replace(",", string.Empty).Replace("?", string.Empty).Replace("*", string.Empty).Replace("+", string.Empty).Replace("\\", string.Empty); wavePeakName = Path.Combine(dir, wavePeakName); return wavePeakName; @@ -15347,7 +15347,7 @@ namespace Nikse.SubtitleEdit.Forms Directory.CreateDirectory(dir); FileInfo fi = new FileInfo(videoFileName); - string name = Sha256Hash(Path.GetFileName(videoFileName) + fi.Length.ToString() + fi.CreationTimeUtc.ToShortDateString()); + string name = Sha256Hash(Path.GetFileName(videoFileName) + fi.Length + fi.CreationTimeUtc.ToShortDateString()); name = name.Replace("=", string.Empty).Replace("/", string.Empty).Replace(",", string.Empty).Replace("?", string.Empty).Replace("*", string.Empty).Replace("+", string.Empty).Replace("\\", string.Empty); name = Path.Combine(dir, name); return name; @@ -16387,7 +16387,7 @@ namespace Nikse.SubtitleEdit.Forms _subtitle.Paragraphs.RemoveAt(update.Index); if (_networkSession.LastSubtitle != null) _networkSession.LastSubtitle.Paragraphs.RemoveAt(update.Index); - _networkSession.AppendToLog(string.Format(_language.NetworkDelete, update.User.UserName, update.User.Ip, update.Index.ToString())); + _networkSession.AppendToLog(string.Format(_language.NetworkDelete, update.User.UserName, update.User.Ip, update.Index)); _networkSession.AdjustUpdateLogToDelete(update.Index); if (deleteIndices.Count > 0) @@ -16414,7 +16414,7 @@ namespace Nikse.SubtitleEdit.Forms _subtitle.Paragraphs.Insert(update.Index, p); if (_networkSession.LastSubtitle != null) _networkSession.LastSubtitle.Paragraphs.Insert(update.Index, new Paragraph(p)); - _networkSession.AppendToLog(string.Format(_language.NetworkInsert, update.User.UserName, update.User.Ip, update.Index.ToString(), update.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); + _networkSession.AppendToLog(string.Format(_language.NetworkInsert, update.User.UserName, update.User.Ip, update.Index, update.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, false); updateListViewStatus = true; _networkSession.AdjustUpdateLogToInsert(update.Index); @@ -16443,7 +16443,7 @@ namespace Nikse.SubtitleEdit.Forms p.EndTime.TotalMilliseconds = update.EndMilliseconds; p.Text = update.Text; SubtitleListview1.SetTimeAndText(update.Index, p); - _networkSession.AppendToLog(string.Format(_language.NetworkUpdate, update.User.UserName, update.User.Ip, update.Index.ToString(), update.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); + _networkSession.AppendToLog(string.Format(_language.NetworkUpdate, update.User.UserName, update.User.Ip, update.Index, update.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, true); updateListViewStatus = true; } @@ -16710,7 +16710,7 @@ namespace Nikse.SubtitleEdit.Forms if (firstUndock) { - Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUnDocked.Left.ToString() + ";" + _videoPlayerUnDocked.Top.ToString() + ";" + _videoPlayerUnDocked.Width + ";" + _videoPlayerUnDocked.Height; + Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUnDocked.Left + @";" + _videoPlayerUnDocked.Top + @";" + _videoPlayerUnDocked.Width + @";" + _videoPlayerUnDocked.Height; } Control control = null; diff --git a/src/Forms/MergeDoubleLines.cs b/src/Forms/MergeDoubleLines.cs index 8d80e0e43..bdd354f7e 100644 --- a/src/Forms/MergeDoubleLines.cs +++ b/src/Forms/MergeDoubleLines.cs @@ -148,12 +148,15 @@ namespace Nikse.SubtitleEdit.Forms p.EndTime = next.EndTime; if (lastMerged) { - lineNumbers.Append(next.Number.ToString() + ","); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); } else { - lineNumbers.Append(p.Number.ToString() + ","); - lineNumbers.Append(next.Number.ToString() + ","); + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); } lastMerged = true; @@ -170,12 +173,15 @@ namespace Nikse.SubtitleEdit.Forms numberOfMerges++; if (lastMerged) { - lineNumbers.Append(afterNext.Number.ToString() + ","); + lineNumbers.Append(afterNext.Number); + lineNumbers.Append(','); } else { - lineNumbers.Append(p.Number.ToString() + ","); - lineNumbers.Append(afterNext.Number.ToString() + ","); + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(afterNext.Number); + lineNumbers.Append(','); } lastMerged = true; if (!mergedIndexes.Contains(i)) diff --git a/src/Forms/MergeShortLines.cs b/src/Forms/MergeShortLines.cs index 5eb6a79e2..cea7f77f5 100644 --- a/src/Forms/MergeShortLines.cs +++ b/src/Forms/MergeShortLines.cs @@ -158,12 +158,15 @@ namespace Nikse.SubtitleEdit.Forms if (lastMerged) { - lineNumbers.Append(next.Number.ToString() + ","); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); } else { - lineNumbers.Append(p.Number.ToString() + ","); - lineNumbers.Append(next.Number.ToString() + ","); + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); } lastMerged = true; diff --git a/src/Forms/MergeTextWithSameTimeCodes.cs b/src/Forms/MergeTextWithSameTimeCodes.cs index b598ab3dc..4cad7d13b 100644 --- a/src/Forms/MergeTextWithSameTimeCodes.cs +++ b/src/Forms/MergeTextWithSameTimeCodes.cs @@ -198,8 +198,9 @@ namespace Nikse.SubtitleEdit.Forms if (!mergedIndexes.Contains(i - 1)) mergedIndexes.Add(i - 1); - lineNumbers.Append(p.Number.ToString() + ", "); - lineNumbers.Append(next.Number.ToString()); + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(next.Number); } else { diff --git a/src/Forms/NetworkChat.cs b/src/Forms/NetworkChat.cs index bf98d3e53..03ec2dd43 100644 --- a/src/Forms/NetworkChat.cs +++ b/src/Forms/NetworkChat.cs @@ -93,13 +93,13 @@ namespace Nikse.SubtitleEdit.Forms { if (s[deleteFrom] == ' ') deleteFrom--; - while (deleteFrom > 0 && !(breakChars).Contains(s.Substring(deleteFrom, 1))) + while (deleteFrom > 0 && !breakChars.Contains(s[deleteFrom])) { deleteFrom--; } if (deleteFrom == index - 1) { - while (deleteFrom > 0 && (breakChars.Replace(" ", string.Empty)).Contains(s.Substring(deleteFrom - 1, 1))) + while (deleteFrom > 0 && breakChars.Replace(" ", string.Empty).Contains(s[deleteFrom - 1])) { deleteFrom--; } diff --git a/src/Forms/OCRSpellCheck.cs b/src/Forms/OCRSpellCheck.cs index bafe13273..534096ad8 100644 --- a/src/Forms/OCRSpellCheck.cs +++ b/src/Forms/OCRSpellCheck.cs @@ -103,12 +103,12 @@ namespace Nikse.SubtitleEdit.Forms { bool startOk = i == 0; if (!startOk) - startOk = (" <>-\"”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text.Substring(i - 1, 1)); + startOk = (@" <>-""”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i - 1]); if (startOk) { bool endOk = (i + word.Length == richTextBoxParagraph.Text.Length); if (!endOk) - endOk = (" <>-\"”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text.Substring(i + word.Length, 1)); + endOk = (@" <>-""”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i + word.Length]); if (endOk) { richTextBoxParagraph.SelectionStart = i + 1; diff --git a/src/Forms/SetSyncPoint.cs b/src/Forms/SetSyncPoint.cs index 935957c5a..67f0be02c 100644 --- a/src/Forms/SetSyncPoint.cs +++ b/src/Forms/SetSyncPoint.cs @@ -63,7 +63,7 @@ namespace Nikse.SubtitleEdit.Forms subtitleListView1.Fill(subtitle); _guess = subtitle.Paragraphs[index].StartTime.TimeSpan; subtitleListView1.Items[index].Selected = true; - Text = string.Format(Configuration.Settings.Language.SetSyncPoint.Title, subtitle.Paragraphs[index].Number.ToString() + ": " + subtitle.Paragraphs[index]); + Text = string.Format(Configuration.Settings.Language.SetSyncPoint.Title, subtitle.Paragraphs[index].Number + ": " + subtitle.Paragraphs[index]); labelSubtitle.Text = string.Empty; labelVideoFileName.Text = Configuration.Settings.Language.General.NoVideoLoaded; diff --git a/src/Forms/Settings.cs b/src/Forms/Settings.cs index 8064f25bb..e9b0fc1a2 100644 --- a/src/Forms/Settings.cs +++ b/src/Forms/Settings.cs @@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Forms return string.Empty; Uri pathUri = new Uri(fileName); - if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString())) + if (!folder.EndsWith(Path.DirectorySeparatorChar)) folder += Path.DirectorySeparatorChar; Uri folderUri = new Uri(folder); return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)); diff --git a/src/Forms/SpellCheck.cs b/src/Forms/SpellCheck.cs index 2138a5ca5..7de1b9321 100644 --- a/src/Forms/SpellCheck.cs +++ b/src/Forms/SpellCheck.cs @@ -433,7 +433,7 @@ namespace Nikse.SubtitleEdit.Forms if (textBoxWord.Text.Length < 2) return; - string s = textBoxWord.Text.Substring(0, 1).ToUpper() + textBoxWord.Text.Substring(1); + string s = char.ToUpper(textBoxWord.Text[0]) + textBoxWord.Text.Substring(1); if (checkBoxAutoChangeNames.Checked && _suggestions != null && _suggestions.Contains(s)) { ChangeWord = s; @@ -736,7 +736,7 @@ namespace Nikse.SubtitleEdit.Forms suggestions = DoSuggest(_currentWord); //TODO: 0.9.6 fails on "Lt'S" if (_languageName.StartsWith("fr_") && (_currentWord.StartsWith("I'") || _currentWord.StartsWith("I’"))) { - if (_currentWord.Length > 3 && Utilities.LowercaseLetters.Contains(_currentWord[2].ToString())) + if (_currentWord.Length > 3 && Utilities.LowercaseLetters.Contains(_currentWord[2])) { if (_currentSpellCheckWord.Index > 3) { @@ -746,7 +746,7 @@ namespace Nikse.SubtitleEdit.Forms for (int i = 0; i < suggestions.Count; i++) { if (suggestions[i].StartsWith("L'") || suggestions[i].StartsWith("L’")) - suggestions[i] = suggestions[i].Remove(0, 1).Insert(0, "l"); + suggestions[i] = @"l" + suggestions[i].Substring(1); } } } @@ -764,9 +764,9 @@ namespace Nikse.SubtitleEdit.Forms } } - if (AutoFixNames && _currentWord.Length > 1 && suggestions.Contains(_currentWord.Substring(0, 1).ToUpper() + _currentWord.Substring(1))) + if (AutoFixNames && _currentWord.Length > 1 && suggestions.Contains(char.ToUpper(_currentWord[0]) + _currentWord.Substring(1))) { - ChangeWord = _currentWord.Substring(0, 1).ToUpper() + _currentWord.Substring(1); + ChangeWord = char.ToUpper(_currentWord[0]) + _currentWord.Substring(1); DoAction(SpellCheckAction.ChangeAll); return; } @@ -776,9 +776,9 @@ namespace Nikse.SubtitleEdit.Forms DoAction(SpellCheckAction.ChangeAll); return; } - else if (AutoFixNames && _currentWord.Length > 1 && _namesEtcList.Contains(_currentWord.Substring(0, 1).ToUpper() + _currentWord.Substring(1))) + else if (AutoFixNames && _currentWord.Length > 1 && _namesEtcList.Contains(char.ToUpper(_currentWord[0]) + _currentWord.Substring(1))) { - ChangeWord = _currentWord.Substring(0, 1).ToUpper() + _currentWord.Substring(1); + ChangeWord = char.ToUpper(_currentWord[0]) + _currentWord.Substring(1); DoAction(SpellCheckAction.ChangeAll); return; } @@ -825,7 +825,7 @@ namespace Nikse.SubtitleEdit.Forms var sb = new StringBuilder(); for (int i = 0; i < s.Length; i++) { - if (SplitChars.Contains(s.Substring(i, 1))) + if (SplitChars.Contains(s[i])) { if (sb.Length > 0) list.Add(new SpellCheckWord() { Text = sb.ToString(), Index = i - sb.Length }); @@ -833,7 +833,7 @@ namespace Nikse.SubtitleEdit.Forms } else { - sb.Append(s.Substring(i, 1)); + sb.Append(s[i]); } } if (sb.Length > 0) @@ -859,11 +859,11 @@ namespace Nikse.SubtitleEdit.Forms int start = s.IndexOf(name); while (start >= 0) { - bool startOk = start == 0 || " -.,?!:;\"“”()[]{}|<>/+\r\n¿¡…—–♪♫„“".Contains(s.Substring(start - 1, 1)); + bool startOk = start == 0 || " -.,?!:;\"“”()[]{}|<>/+\r\n¿¡…—–♪♫„“".Contains(s[start - 1]); if (startOk) { int end = start + name.Length; - bool endOk = end >= s.Length || " -.,?!:;\"“”()[]{}|<>/+\r\n¿¡…—–♪♫„“".Contains(s.Substring(end, 1)); + bool endOk = end >= s.Length || " -.,?!:;\"“”()[]{}|<>/+\r\n¿¡…—–♪♫„“".Contains(s[end]); if (endOk) s = s.Remove(start, name.Length).Insert(start, string.Empty.PadLeft(name.Length)); } @@ -928,9 +928,9 @@ namespace Nikse.SubtitleEdit.Forms { found = true; int endIndexPlus = indexStart + wordWithDashesOrPeriods.Length; - bool startOk = indexStart == 0 || (" (['\"" + Environment.NewLine).Contains(text.Substring(indexStart - 1, 1)); + bool startOk = indexStart == 0 || (@" (['""" + Environment.NewLine).Contains(text[indexStart - 1]); bool endOk = endIndexPlus == text.Length; - if (!endOk && endIndexPlus < text.Length && (",!?:;. ])<'\"").Contains(text.Substring(endIndexPlus, 1))) + if (!endOk && endIndexPlus < text.Length && @",!?:;. ])<'""".Contains(text[endIndexPlus])) endOk = true; if (startOk && endOk) { diff --git a/src/Forms/SubStationAlphaStyles.cs b/src/Forms/SubStationAlphaStyles.cs index e4b5c2928..4422b2a12 100644 --- a/src/Forms/SubStationAlphaStyles.cs +++ b/src/Forms/SubStationAlphaStyles.cs @@ -695,7 +695,7 @@ namespace Nikse.SubtitleEdit.Forms if (indexOfEvents > 0) { int i = indexOfEvents - 1; - while (i > 0 && Environment.NewLine.Contains(Header[i].ToString())) + while (i > 0 && Environment.NewLine.Contains(Header[i])) i--; Header = Header.Insert(i + 1, Environment.NewLine + newLine); } @@ -726,7 +726,7 @@ namespace Nikse.SubtitleEdit.Forms bool doRepeat = true; while (doRepeat) { - style = GetSsaStyle(Configuration.Settings.Language.SubStationAlphaStyles.New + count.ToString()); + style = GetSsaStyle(Configuration.Settings.Language.SubStationAlphaStyles.New + count); doRepeat = GetSsaStyle(style.Name).LoadedFromHeader; count++; } @@ -1165,14 +1165,14 @@ namespace Nikse.SubtitleEdit.Forms if (GetSsaStyle(style.Name).LoadedFromHeader) { int count = 2; - bool doRepeat = GetSsaStyle(style.Name + count.ToString()).LoadedFromHeader; + bool doRepeat = GetSsaStyle(style.Name + count).LoadedFromHeader; while (doRepeat) { - doRepeat = GetSsaStyle(style.Name + count.ToString()).LoadedFromHeader; + doRepeat = GetSsaStyle(style.Name + count).LoadedFromHeader; count++; } - style.RawLine = style.RawLine.Replace(" " + style.Name + ",", " " + style.Name + count.ToString() + ","); - style.Name = style.Name + count.ToString(); + style.RawLine = style.RawLine.Replace(" " + style.Name + ",", " " + style.Name + count + ","); + style.Name = style.Name + count; } _doUpdate = false; diff --git a/src/Forms/SyncPointsSync.cs b/src/Forms/SyncPointsSync.cs index a5cf5fe39..753b42b58 100644 --- a/src/Forms/SyncPointsSync.cs +++ b/src/Forms/SyncPointsSync.cs @@ -155,7 +155,7 @@ namespace Nikse.SubtitleEdit.Forms p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _subtitle.Paragraphs[i].Duration.TotalMilliseconds; SubtitleListview1.SetStartTime(i, p); - var item = new ListBoxSyncPoint() { Index = i, Text = _subtitle.Paragraphs[i].Number.ToString() + " - " + p.StartTime }; + var item = new ListBoxSyncPoint { Index = i, Text = _subtitle.Paragraphs[i].Number + " - " + p.StartTime }; listBoxSyncPoints.Items.Add(item); SubtitleListview1.SetBackgroundColor(i, Color.Green); SubtitleListview1.SetNumber(i, "* * * *"); diff --git a/src/Forms/TimedTextStyles.cs b/src/Forms/TimedTextStyles.cs index 2cab16495..ed1089228 100644 --- a/src/Forms/TimedTextStyles.cs +++ b/src/Forms/TimedTextStyles.cs @@ -44,7 +44,7 @@ namespace Nikse.SubtitleEdit.Forms _xmlHead = _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr); foreach (FontFamily ff in FontFamily.Families) - comboBoxFontName.Items.Add(ff.Name.Substring(0, 1).ToLower() + ff.Name.Substring(1)); + comboBoxFontName.Items.Add(char.ToLower(ff.Name[0]) + ff.Name.Substring(1)); InitializeListView(); diff --git a/src/Forms/VobSubNOcrTrain.cs b/src/Forms/VobSubNOcrTrain.cs index 7fff3421e..32db0857f 100644 --- a/src/Forms/VobSubNOcrTrain.cs +++ b/src/Forms/VobSubNOcrTrain.cs @@ -239,7 +239,7 @@ namespace Nikse.SubtitleEdit.Forms } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } i++; } diff --git a/src/Forms/VobSubOcr.cs b/src/Forms/VobSubOcr.cs index dfde1f2e9..d2db9cfee 100644 --- a/src/Forms/VobSubOcr.cs +++ b/src/Forms/VobSubOcr.cs @@ -4443,28 +4443,28 @@ namespace Nikse.SubtitleEdit.Forms private string FixNocrHardcodedStuff(string line) { // fix I/l - int start = line.IndexOf("I", StringComparison.Ordinal); + int start = line.IndexOf('I'); while (start > 0) { - if (start > 0 && line[start - 1].ToString() != line[start - 1].ToString().ToUpper()) + if (start > 0 && char.IsLower(line[start - 1])) line = line.Remove(start, 1).Insert(start, "l"); - else if (start < line.Length - 1 && line[start + 1].ToString() != line[start + 1].ToString().ToUpper()) + else if (start < line.Length - 1 && char.IsLower(line[start + 1])) line = line.Remove(start, 1).Insert(start, "l"); start++; - start = line.IndexOf("I", start); + start = line.IndexOf('I', start); } - start = line.IndexOf("l"); + start = line.IndexOf('l'); while (start > 0) { - if (start < line.Length - 1 && line[start + 1].ToString() != line[start + 1].ToString().ToLower()) + if (start < line.Length - 1 && char.IsUpper(line[start + 1])) line = line.Remove(start, 1).Insert(start, "I"); start++; - start = line.IndexOf("l", start, StringComparison.Ordinal); + start = line.IndexOf('l', start); } if (line.Contains('l')) { if (line.StartsWith('l')) - line = line.Remove(0, 1).Insert(0, "I"); + line = @"I" + line.Substring(1); if (line.StartsWith("l")) line = line.Remove(3, 1).Insert(3, "I"); if (line.StartsWith("- l")) @@ -5598,10 +5598,10 @@ namespace Nikse.SubtitleEdit.Forms var nbmp = new NikseBitmap(bmp); nbmp.ReplaceYellowWithWhite(); // optimized replace - string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; + string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid() + ".png"; var b = nbmp.GetBitmap(); b.Save(tempTiffFileName, System.Drawing.Imaging.ImageFormat.Png); - string tempTextFileName = Path.GetTempPath() + Guid.NewGuid().ToString(); + string tempTextFileName = Path.GetTempPath() + Guid.NewGuid(); b.Dispose(); var process = new Process(); @@ -5713,7 +5713,7 @@ namespace Nikse.SubtitleEdit.Forms Split(new[] { ' ', '.', '?', '!', '(', ')', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in arr) { - if (s.Length == 1 && !"♪♫-:'”1234567890&aAI\"".Contains(s)) + if (s.Length == 1 && !@"♪♫-:'”1234567890&aAI""".Contains(s)) count++; } if (count > 0) @@ -5996,7 +5996,7 @@ namespace Nikse.SubtitleEdit.Forms { unItalicText = "♪ " + unItalicText.Remove(0, 2).TrimStart(); } - if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && unItalicText.Replace("", string.Empty).Replace("", string.Empty).Substring(1, 1) == " ") + if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && unItalicText.Replace("", string.Empty).Replace("", string.Empty)[1] == ' ') { bool ita = unItalicText.StartsWith("") && unItalicText.EndsWith(""); unItalicText = Utilities.RemoveHtmlTags(unItalicText); @@ -6004,7 +6004,7 @@ namespace Nikse.SubtitleEdit.Forms if (ita) unItalicText = "" + unItalicText + ""; } - if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && unItalicText.Replace("", string.Empty).Replace("", string.Empty).Substring(2, 1) == " ") + if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && unItalicText.Replace("", string.Empty).Replace("", string.Empty)[2] == ' ') { bool ita = unItalicText.StartsWith("") && unItalicText.EndsWith(""); unItalicText = Utilities.RemoveHtmlTags(unItalicText); @@ -6128,7 +6128,7 @@ namespace Nikse.SubtitleEdit.Forms { string w = unItalicText.Substring(0, unItalicText.Length - 4); int wIdx = w.Length - 1; - while (wIdx >= 0 && !(" .,!?<>:;'-$@£()[]<>/\"".Contains(w[wIdx].ToString()))) + while (wIdx >= 0 && !@" .,!?<>:;'-$@£()[]<>/""".Contains(w[wIdx])) { wIdx--; } @@ -6144,7 +6144,7 @@ namespace Nikse.SubtitleEdit.Forms { string w = unItalicText; int wIdx = w.Length - 1; - while (wIdx >= 0 && !(" .,!?<>:;'-$@£()[]<>/\"".Contains(w[wIdx].ToString()))) + while (wIdx >= 0 && !@" .,!?<>:;'-$@£()[]<>/""".Contains(w[wIdx])) { wIdx--; } @@ -6307,7 +6307,7 @@ namespace Nikse.SubtitleEdit.Forms //if (!tmp.TrimEnd().EndsWith("...")) //{ // tmp = tmp.TrimEnd('.').TrimEnd(); - // if (tmp.Length > 2 && Utilities.LowercaseLetters.Contains(tmp.Substring(tmp.Length - 1, 1))) + // if (tmp.Length > 2 && Utilities.LowercaseLetters.Contains(tmp[tmp.Length - 1])) // { // if (_nocrChars == null) // _nocrChars = LoadNOcrForTesseract("Nikse.SubtitleEdit.Resources.nOCR_TesseractHelper.xml.zip"); diff --git a/src/Forms/Watermark.cs b/src/Forms/Watermark.cs index 593211c3d..90ed07eff 100644 --- a/src/Forms/Watermark.cs +++ b/src/Forms/Watermark.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Text; using System.Windows.Forms; using Nikse.SubtitleEdit.Logic; @@ -9,8 +10,8 @@ namespace Nikse.SubtitleEdit.Forms { public sealed partial class Watermark : Form { - private const string zeroWhiteSpace = "\u200B"; - private const string zeroWidthNoBreakSpace = "\uFEFF"; + private const char zeroWhiteSpace = '\u200B'; + private const char zeroWidthNoBreakSpace = '\uFEFF'; private int _firstSelectedIndex; @@ -68,15 +69,15 @@ namespace Nikse.SubtitleEdit.Forms int letter = 0; while (i < input.Length) { - string s = input.Substring(i, 1); - if (s == zeroWhiteSpace) + var c = input[i]; + if (c == zeroWhiteSpace) { if (letter > 0) sb.Append(Encoding.ASCII.GetString(new byte[] { (byte)letter })); letterOn = true; letter = 0; } - else if (s == zeroWidthNoBreakSpace && letterOn) + else if (c == zeroWidthNoBreakSpace && letterOn) { letter++; } @@ -166,8 +167,10 @@ namespace Nikse.SubtitleEdit.Forms private static void RemoveWaterMark(Subtitle subtitle) { + var zws = zeroWhiteSpace.ToString(CultureInfo.InvariantCulture); + var zwnbs = zeroWidthNoBreakSpace.ToString(CultureInfo.InvariantCulture); foreach (Paragraph p in subtitle.Paragraphs) - p.Text = p.Text.Replace(zeroWhiteSpace, string.Empty).Replace(zeroWidthNoBreakSpace, string.Empty); + p.Text = p.Text.Replace(zws, string.Empty).Replace(zwnbs, string.Empty); } private void buttonGenerate_Click(object sender, EventArgs e) diff --git a/src/Logic/Configuration.cs b/src/Logic/Configuration.cs index 3d9116cb5..8856f644a 100644 --- a/src/Logic/Configuration.cs +++ b/src/Logic/Configuration.cs @@ -228,7 +228,7 @@ namespace Nikse.SubtitleEdit.Logic else Instance._baseDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - if (!Instance._baseDir.EndsWith(Path.DirectorySeparatorChar.ToString())) + if (!Instance._baseDir.EndsWith(Path.DirectorySeparatorChar)) Instance._baseDir += Path.DirectorySeparatorChar; } return Instance._baseDir; diff --git a/src/Logic/Forms/RemoveTextForHI.cs b/src/Logic/Forms/RemoveTextForHI.cs index 2c1bcbbba..8e8cc80ad 100644 --- a/src/Logic/Forms/RemoveTextForHI.cs +++ b/src/Logic/Forms/RemoveTextForHI.cs @@ -134,7 +134,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms bool remove = true; if (indexOfColon > 0 && indexOfColon < s.Length - 1) { - if ("1234567890".Contains(s.Substring(indexOfColon - 1, 1)) && "1234567890".Contains(s.Substring(indexOfColon + 1, 1))) + if (char.IsDigit(s[indexOfColon - 1]) && char.IsDigit(s[indexOfColon + 1])) remove = false; } if (s.StartsWith("Previously on") || s.StartsWith("Previously on")) @@ -213,7 +213,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms endIndex = exclaIndex; if (colonIndex > 0 && colonIndex < s2.Length - 1) { - if ("1234567890".Contains(s2.Substring(colonIndex - 1, 1)) && "1234567890".Contains(s2.Substring(colonIndex + 1, 1))) + if (char.IsDigit(s2[colonIndex - 1]) && char.IsDigit(s2[colonIndex + 1])) endIndex = -10; } if (endIndex == -1) @@ -258,7 +258,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms //line continuation? if (arr0.Length > 0 && arr1.Length > 1 && (Utilities.LowercaseLetters + ",").Contains(arr0.Substring(arr0.Length - 1)) && - Utilities.LowercaseLetters.Contains(arr1.Substring(0, 1))) + Utilities.LowercaseLetters.Contains(arr1[0])) { if (new StripableText(arr[1]).Pre.Contains("...") == false) insertDash = false; @@ -433,7 +433,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms string part0 = arr[0].Trim().Replace("", string.Empty).Trim(); if (!part0.EndsWith(',') && (!part0.EndsWith('-') || noOfNamesRemovedNotInLineOne > 0)) { - if (part0.Length > 0 && ".!?".Contains(part0.Substring(part0.Length - 1))) + if (part0.Length > 0 && @".!?".Contains(part0[part0.Length - 1])) { if (noOfNamesRemovedNotInLineOne > 0) { @@ -572,7 +572,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms if (!_interjectionList.Contains(upper)) _interjectionList.Add(upper); - string pascalCasing = s.Substring(0, 1).ToUpper() + s.Remove(0, 1); + string pascalCasing = char.ToUpper(s[0]) + s.Substring(1); if (!_interjectionList.Contains(pascalCasing)) _interjectionList.Add(pascalCasing); } @@ -684,7 +684,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms } if (temp.Length > 0 && s[0].ToString(CultureInfo.InvariantCulture) != s[0].ToString(CultureInfo.InvariantCulture).ToLower()) { - temp = temp.Remove(0, 1).Insert(0, temp[0].ToString(CultureInfo.InvariantCulture).ToUpper()); + temp = char.ToUpper(temp[0]) + temp.Substring(1); doRepeat = true; } diff --git a/src/Logic/IfoParser.cs b/src/Logic/IfoParser.cs index 75166fc6b..ecd56b1db 100644 --- a/src/Logic/IfoParser.cs +++ b/src/Logic/IfoParser.cs @@ -156,7 +156,7 @@ namespace Nikse.SubtitleEdit.Logic audioStream.CodingMode = ArrayOfAudioMode[(BinToInt(MidStr(data, 0, 3)))]; audioStream.Channels = BinToInt(MidStr(data, 13, 3)) + 1; _fs.Read(buffer, 0, 2); - audioStream.LangageCode = Convert.ToChar(buffer[0]).ToString() + Convert.ToChar(buffer[1]).ToString(); + audioStream.LangageCode = new string(new[] { Convert.ToChar(buffer[0]), Convert.ToChar(buffer[1]) }); if (ArrayOfLanguageCode.Contains(audioStream.LangageCode)) audioStream.Langage = ArrayOfLanguage[ArrayOfLanguageCode.IndexOf(audioStream.LangageCode)]; _fs.Seek(1, SeekOrigin.Current); @@ -172,7 +172,7 @@ namespace Nikse.SubtitleEdit.Logic for (int i = 0; i < _vtsVobs.NumberOfSubtitles; i++) { _fs.Read(buffer, 0, 2); - string languageTwoLetter = Convert.ToChar(buffer[0]).ToString() + Convert.ToChar(buffer[1]).ToString(); + var languageTwoLetter = new string(new[] { Convert.ToChar(buffer[0]), Convert.ToChar(buffer[1]) }); _vtsVobs.Subtitles.Add(InterpretLangageCode(languageTwoLetter)); string subtitleFormat = string.Empty; diff --git a/src/Logic/Networking/NikseWebServiceSession.cs b/src/Logic/Networking/NikseWebServiceSession.cs index 3a8166074..72a92bf88 100644 --- a/src/Logic/Networking/NikseWebServiceSession.cs +++ b/src/Logic/Networking/NikseWebServiceSession.cs @@ -275,14 +275,14 @@ namespace Nikse.SubtitleEdit.Logic.Networking { sb.Append(index + ", "); AdjustUpdateLogToDelete(index); - AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkDelete, CurrentUser.UserName, CurrentUser.Ip, index.ToString())); + AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkDelete, CurrentUser.UserName, CurrentUser.Ip, index)); } } internal void InsertLine(int index, Paragraph newParagraph) { _seWs.InsertLine(SessionId, index, (int)newParagraph.StartTime.TotalMilliseconds, (int)newParagraph.EndTime.TotalMilliseconds, newParagraph.Text, CurrentUser); - AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkInsert, CurrentUser.UserName, CurrentUser.Ip, index.ToString(), newParagraph.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); + AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkInsert, CurrentUser.UserName, CurrentUser.Ip, index, newParagraph.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString))); } internal void AdjustUpdateLogToInsert(int index) diff --git a/src/Logic/OCR/OcrFixEngine.cs b/src/Logic/OCR/OcrFixEngine.cs index b0a26a11a..ffb5eeac8 100644 --- a/src/Logic/OCR/OcrFixEngine.cs +++ b/src/Logic/OCR/OcrFixEngine.cs @@ -415,7 +415,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr string lastWord = null; for (int i = 0; i < text.Length; i++) { - if (" ¡¿,.!?:;()[]{}+-£\"#&%\r\n".Contains(text[i].ToString())) // removed $ + if (" ¡¿,.!?:;()[]{}+-£\"#&%\r\n".Contains(text[i])) // removed $ { if (word.Length > 0) { @@ -493,22 +493,22 @@ namespace Nikse.SubtitleEdit.Logic.Ocr lastLine.EndsWith(".") || lastLine.EndsWith("!") || lastLine.EndsWith("?"); if (text.StartsWith(tag.TrimStart(), StringComparison.Ordinal) && text.Length > 3) { - if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text.Substring(2, 1))) + if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text[2])) { - text = text.Remove(0, 1).Insert(0, "L"); + text = @"L" + text.Substring(1); } - else if (Utilities.LowercaseLetters.Contains(text.Substring(2, 1))) + else if (Utilities.LowercaseLetters.Contains(text[2])) { - text = text.Remove(0, 1).Insert(0, "l"); + text = @"l" + text.Substring(1); } } else if (text.StartsWith("" + tag.TrimStart(), StringComparison.Ordinal) && text.Length > 6) { - if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text.Substring(5, 1))) + if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text[5])) { text = text.Remove(3, 1).Insert(3, "L"); } - else if (Utilities.LowercaseLetters.Contains(text.Substring(5, 1))) + else if (Utilities.LowercaseLetters.Contains(text[5])) { text = text.Remove(3, 1).Insert(3, "l"); } @@ -524,11 +524,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr if (start == 1 && text.StartsWith('-')) endingBeforeThis = true; - if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text.Substring(start + 3, 1))) + if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text[start + 3])) { text = text.Remove(start + 1, 1).Insert(start + 1, "L"); } - else if (Utilities.LowercaseLetters.Contains(text.Substring(start + 3, 1))) + else if (Utilities.LowercaseLetters.Contains(text[start + 3])) { text = text.Remove(start + 1, 1).Insert(start + 1, "l"); } @@ -544,11 +544,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith("."); if (start < text.Length - 5) { - if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text.Substring(start + 2 + Environment.NewLine.Length, 1))) + if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text[start + 2 + Environment.NewLine.Length])) { text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "L"); } - else if (Utilities.LowercaseLetters.Contains(text.Substring(start + 2 + Environment.NewLine.Length, 1))) + else if (Utilities.LowercaseLetters.Contains(text[start + 2 + Environment.NewLine.Length])) { text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "l"); } @@ -564,11 +564,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith("."); if (start < text.Length - 8) { - if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text.Substring(start + 5 + Environment.NewLine.Length, 1))) + if (endingBeforeThis || Utilities.UppercaseLetters.Contains(text[start + 5 + Environment.NewLine.Length])) { text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "L"); } - else if (Utilities.LowercaseLetters.Contains(text.Substring(start + 5 + Environment.NewLine.Length, 1))) + else if (Utilities.LowercaseLetters.Contains(text[start + 5 + Environment.NewLine.Length])) { text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "l"); } @@ -620,7 +620,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr { bool doFix = true; - if (match.Index + 4 < text.Length && text[match.Index + 3] == '/' && "0123456789".Contains(text[match.Index + 4].ToString())) + if (match.Index + 4 < text.Length && text[match.Index + 3] == '/' && char.IsDigit(text[match.Index + 4])) doFix = false; if (doFix) @@ -979,7 +979,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr { if (word[match.Index] == '0') { - if (match.Index == 0 || !"123456789".Contains(word[match.Index - 1].ToString())) + if (match.Index == 0 || !@"123456789".Contains(word[match.Index - 1])) { string oldText = word; word = word.Substring(0, match.Index) + "o"; @@ -1139,7 +1139,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr return true; } - if (line.Length > 5 && line[line.Length - 3] == '.' && Utilities.AllLetters.Contains(line[line.Length - 2].ToString())) + if (line.Length > 5 && line[line.Length - 3] == '.' && Utilities.AllLetters.Contains(line[line.Length - 2])) return true; return false; @@ -1170,14 +1170,14 @@ namespace Nikse.SubtitleEdit.Logic.Ocr bool hasDotDot = input.Contains("..") || input.Contains(". ."); if (hasDotDot) { - if (input.Length > 5 && input.StartsWith("..") && Utilities.AllLettersAndNumbers.Contains(input.Substring(2, 1))) + if (input.Length > 5 && input.StartsWith("..") && Utilities.AllLettersAndNumbers.Contains(input[2])) input = "..." + input.Remove(0, 2); - if (input.Length > 7 && input.StartsWith("..") && Utilities.AllLettersAndNumbers.Contains(input.Substring(5, 1))) + if (input.Length > 7 && input.StartsWith("..") && Utilities.AllLettersAndNumbers.Contains(input[5])) input = "..." + input.Remove(0, 5); - if (input.Length > 5 && input.StartsWith(".. ") && Utilities.AllLettersAndNumbers.Contains(input.Substring(3, 1))) + if (input.Length > 5 && input.StartsWith(".. ") && Utilities.AllLettersAndNumbers.Contains(input[3])) input = "..." + input.Remove(0, 3); - if (input.Length > 7 && input.StartsWith(".. ") && Utilities.AllLettersAndNumbers.Contains(input.Substring(6, 1))) + if (input.Length > 7 && input.StartsWith(".. ") && Utilities.AllLettersAndNumbers.Contains(input[6])) input = "..." + input.Remove(0, 6); if (input.Contains(Environment.NewLine + ".. ")) input = input.Replace(Environment.NewLine + ".. ", Environment.NewLine + "..."); @@ -1257,24 +1257,24 @@ namespace Nikse.SubtitleEdit.Logic.Ocr input = input.Remove(0, 1); } - if (input.Length > 2 && input[0] == '-' && Utilities.UppercaseLetters.Contains(input[1].ToString())) + if (input.Length > 2 && input[0] == '-' && Utilities.UppercaseLetters.Contains(input[1])) { input = input.Insert(1, " "); } - if (input.Length > 5 && input.StartsWith("-") && Utilities.UppercaseLetters.Contains(input[4].ToString())) + if (input.Length > 5 && input.StartsWith("-") && Utilities.UppercaseLetters.Contains(input[4])) { input = input.Insert(4, " "); } int idx = input.IndexOf(Environment.NewLine + "-", StringComparison.Ordinal); - if (idx > 0 && idx + Environment.NewLine.Length + 1 < input.Length && Utilities.UppercaseLetters.Contains(input[idx + Environment.NewLine.Length + 1].ToString())) + if (idx > 0 && idx + Environment.NewLine.Length + 1 < input.Length && Utilities.UppercaseLetters.Contains(input[idx + Environment.NewLine.Length + 1])) { input = input.Insert(idx + Environment.NewLine.Length + 1, " "); } idx = input.IndexOf(Environment.NewLine + "-", StringComparison.Ordinal); - if (idx > 0 && Utilities.UppercaseLetters.Contains(input[idx + Environment.NewLine.Length + 4].ToString())) + if (idx > 0 && Utilities.UppercaseLetters.Contains(input[idx + Environment.NewLine.Length + 4])) { input = input.Insert(idx + Environment.NewLine.Length + 4, " "); } @@ -1290,22 +1290,22 @@ namespace Nikse.SubtitleEdit.Logic.Ocr var st = new StripableText(input); if (lastLine == null || (!lastLine.EndsWith("...") && !EndsWithAbbreviation(lastLine, abbreviationList))) { - if (st.StrippedText.Length > 0 && st.StrippedText[0].ToString() != st.StrippedText[0].ToString().ToUpper() && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && !st.Pre.EndsWith("...")) + if (st.StrippedText.Length > 0 && !char.IsUpper(st.StrippedText[0]) && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && !st.Pre.EndsWith("...")) { - string uppercaseLetter = st.StrippedText[0].ToString().ToUpper(); - if (st.StrippedText.Length > 1 && uppercaseLetter == "L" && "abcdfghjklmnpqrstvwxz".Contains(st.StrippedText[1].ToString())) - uppercaseLetter = "I"; + var uppercaseLetter = char.ToUpper(st.StrippedText[0]); + if (st.StrippedText.Length > 1 && uppercaseLetter == 'L' && @"abcdfghjklmnpqrstvwxz".Contains(st.StrippedText[1])) + uppercaseLetter = 'I'; if ((st.StrippedText.StartsWith("lo ") || st.StrippedText == "lo.") && _threeLetterIsoLanguageName == "ita") - uppercaseLetter = "I"; + uppercaseLetter = 'I'; if ((st.StrippedText.StartsWith("k ") || st.StrippedText.StartsWith("m ") || st.StrippedText.StartsWith("n ") || st.StrippedText.StartsWith("r ") || st.StrippedText.StartsWith("s ") || st.StrippedText.StartsWith("t ")) && st.Pre.EndsWith('\'') && _threeLetterIsoLanguageName == "nld") - uppercaseLetter = st.StrippedText.Substring(0, 1); + uppercaseLetter = st.StrippedText[0]; if ((st.StrippedText.StartsWith("l-I'll ") || st.StrippedText.StartsWith("l-l'll ")) && _threeLetterIsoLanguageName == "eng") { - uppercaseLetter = "I"; + uppercaseLetter = 'I'; st.StrippedText = "I-I" + st.StrippedText.Remove(0, 3); } - st.StrippedText = st.StrippedText.Remove(0, 1).Insert(0, uppercaseLetter); + st.StrippedText = uppercaseLetter + st.StrippedText.Substring(1); input = st.Pre + st.StrippedText + st.Post; } } @@ -1315,8 +1315,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr if ((lastLine == null || !lastLine.Contains('"')) && input.EndsWith("\".") && input.IndexOf('"') == input.LastIndexOf('"') && input.Length > 3) { - string lastChar = input.Substring(input.Length - 3, 1); - if (!"0123456789".Contains(lastChar)) + var lastChar = input[input.Length - 3]; + if (!char.IsDigit(lastChar)) { int position = input.Length - 2; input = input.Remove(position).Insert(position, "..."); @@ -1331,7 +1331,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr { bool doFix = true; - if (match.Index + 4 < input.Length && input[match.Index + 3] == '/' && "0123456789".Contains(input[match.Index + 4].ToString())) + if (match.Index + 4 < input.Length && input[match.Index + 3] == '/' && char.IsDigit(input[match.Index + 4])) doFix = false; if (doFix) @@ -1401,9 +1401,9 @@ namespace Nikse.SubtitleEdit.Logic.Ocr pre += ""; newText = newText.Remove(0, 3); } - while (newText.Length > 1 && " -\"['¶(".Contains(newText.Substring(0, 1))) + while (newText.Length > 1 && @" -""['¶(".Contains(newText[0])) { - pre += newText.Substring(0, 1); + pre += newText[0]; newText = newText.Substring(1); } if (newText.StartsWith("")) @@ -1518,10 +1518,10 @@ namespace Nikse.SubtitleEdit.Logic.Ocr int start = tempLine.IndexOf(name, StringComparison.Ordinal); if (start >= 0) { - if (start == 0 || (Environment.NewLine + " ¡¿,.!?:;()[]{}+-$£\"”“#&%…—♪").Contains(tempLine[start - 1].ToString())) + if (start == 0 || (Environment.NewLine + @" ¡¿,.!?:;()[]{}+-$£""”“#&%…—♪").Contains(tempLine[start - 1])) { int end = start + name.Length; - if (end >= tempLine.Length || (Environment.NewLine + " ¡¿,.!?:;()[]{}+-$£\"”“#&%…—♪").Contains(tempLine[end].ToString())) + if (end >= tempLine.Length || (Environment.NewLine + @" ¡¿,.!?:;()[]{}+-$£""”“#&%…—♪").Contains(tempLine[end])) tempLine = tempLine.Remove(start, name.Length); } } @@ -1727,9 +1727,9 @@ namespace Nikse.SubtitleEdit.Logic.Ocr int uppercase = 0; for (int i = 0; i < word.Length; i++) { - if (Utilities.LowercaseLetters.Contains(word.Substring(i, 1))) + if (Utilities.LowercaseLetters.Contains(word[i])) lowercase++; - else if (Utilities.UppercaseLetters.Contains(word.Substring(i, 1))) + else if (Utilities.UppercaseLetters.Contains(word[i])) uppercase++; } if (uppercase > lowercase) @@ -1823,7 +1823,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr _wordSkipList.Add(_spellCheck.Word); _wordSkipList.Add(_spellCheck.Word.ToUpper()); if (_spellCheck.Word.Length > 1) - _wordSkipList.Add(_spellCheck.Word.Substring(0, 1).ToUpper() + _spellCheck.Word.Substring(1)); + _wordSkipList.Add(char.ToUpper(_spellCheck.Word[0]) + _spellCheck.Word.Substring(1)); break; case OcrSpellCheck.Action.SkipOnce: break; @@ -1855,14 +1855,14 @@ namespace Nikse.SubtitleEdit.Logic.Ocr { bool startOk = i == 0; if (!startOk) - startOk = (" ¡¿<>-\"”“()[]'‘`´¶♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(text.Substring(i - 1, 1)); + startOk = (@" ¡¿<>-""”“()[]'‘`´¶♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(text[i - 1]); if (!startOk && word.StartsWith(' ')) startOk = true; if (startOk) { bool endOk = (i + word.Length == text.Length); if (!endOk) - endOk = (" ¡¿<>-\"”“()[]'‘`´¶♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(text.Substring(i + word.Length, 1)); + endOk = (@" ¡¿<>-""”“()[]'‘`´¶♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(text[i + word.Length]); if (!endOk) endOk = newWord.EndsWith(' '); if (endOk) @@ -1873,7 +1873,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr } } if (i >= appendFrom) - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } } return sb.ToString(); @@ -1998,10 +1998,10 @@ namespace Nikse.SubtitleEdit.Logic.Ocr { string a = ar[0]; if (a == a.ToUpper()) - a = a.Substring(0, 1) + a.Substring(1).ToLower(); + a = a[0] + a.Substring(1).ToLower(); string b = ar[0]; if (b == b.ToUpper()) - b = b.Substring(0, 1) + b.Substring(1).ToLower(); + b = b[0] + b.Substring(1).ToLower(); if ((DoSpell(a) || IsWordKnownOrNumber(a, word)) && (DoSpell(b) || IsWordKnownOrNumber(b, word))) diff --git a/src/Logic/Settings.cs b/src/Logic/Settings.cs index 6087c9b0e..8cdd0a15a 100644 --- a/src/Logic/Settings.cs +++ b/src/Logic/Settings.cs @@ -306,7 +306,7 @@ namespace Nikse.SubtitleEdit.Logic { if (smpte) { - CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid().ToString(); + CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); CurrentDCinemaLanguage = "en"; CurrentDCinemaFontUri = DCinemaLoadFontResource; CurrentDCinemaFontId = "theFontId"; diff --git a/src/Logic/StripableText.cs b/src/Logic/StripableText.cs index 6f897c265..7d4591a6d 100644 --- a/src/Logic/StripableText.cs +++ b/src/Logic/StripableText.cs @@ -31,13 +31,13 @@ namespace Nikse.SubtitleEdit.Logic OriginalText = text; Pre = string.Empty; - if (text.Length > 0 && !Utilities.AllLettersAndNumbers.Contains(text[0].ToString())) + if (text.Length > 0 && !Utilities.AllLettersAndNumbers.Contains(text[0])) { for (int i = 0; i < 5; i++) { - while (text.Length > 0 && _stripStartCharacters.Contains(text.Substring(0, 1))) + while (text.Length > 0 && _stripStartCharacters.Contains(text[0])) { - Pre += text.Substring(0, 1); + Pre += text[0]; text = text.Substring(1); } @@ -65,13 +65,13 @@ namespace Nikse.SubtitleEdit.Logic } Post = string.Empty; - if (text.Length > 0 && !Utilities.AllLettersAndNumbers.Contains(text[text.Length - 1].ToString())) + if (text.Length > 0 && !Utilities.AllLettersAndNumbers.Contains(text[text.Length - 1])) { for (int i = 0; i < 5; i++) { - while (text.Length > 0 && _stripEndCharacters.Contains(text.Substring(text.Length - 1, 1))) + while (text.Length > 0 && _stripEndCharacters.Contains(text[text.Length - 1])) { - Post = text.Substring(text.Length - 1, 1) + Post; + Post = text[text.Length - 1] + Post; text = text.Substring(0, text.Length - 1); } @@ -132,14 +132,14 @@ 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(), StringComparison.Ordinal)); + Environment.NewLine.EndsWith(lower[start - 1]); if (startOk) { int end = start + name.Length; bool endOk = end <= lower.Length; if (endOk) - endOk = (end == lower.Length) || ((" ,.!?:;')- <\"" + Environment.NewLine).Contains(lower[end].ToString())); + endOk = end == lower.Length || (@" ,.!?:;')- <""" + Environment.NewLine).Contains(lower[end]); if (endOk && StrippedText.Length >= start + name.Length) { @@ -203,7 +203,7 @@ namespace Nikse.SubtitleEdit.Logic if (startWithUppercase && StrippedText.Length > 0 && !Pre.Contains("...")) { - StrippedText = StrippedText.Remove(0, 1).Insert(0, StrippedText[0].ToString().ToUpper()); + StrippedText = char.ToUpper(StrippedText[0]) + StrippedText.Substring(1); } } @@ -224,7 +224,7 @@ namespace Nikse.SubtitleEdit.Logic bool lastWasBreak = false; for (int i = 0; i < StrippedText.Length; i++) { - string s = StrippedText[i].ToString(); + var s = StrippedText[i]; if (lastWasBreak) { if (("\"`´'()<>!?.- " + Environment.NewLine).Contains(s)) @@ -235,7 +235,7 @@ namespace Nikse.SubtitleEdit.Logic { // tags sb.Append(s); } - else if (sb.EndsWith('<') && s == "/" && i + 2 < StrippedText.Length && StrippedText[i + 2] == '>') + else if (sb.EndsWith('<') && s == '/' && i + 2 < StrippedText.Length && StrippedText[i + 2] == '>') { // tags sb.Append(s); } @@ -246,26 +246,26 @@ namespace Nikse.SubtitleEdit.Logic } else { - if (".!?:;)]}([{".Contains(s)) + if (@".!?:;)]}([{".Contains(s)) { sb.Append(s); } else { lastWasBreak = false; - sb.Append(s.ToUpper()); + sb.Append(char.ToUpper(s)); } } } else { sb.Append(s); - if (".!?:;)]}([{".Contains(s)) + if (@".!?:;)]}([{".Contains(s)) { - if (s == "]" && sb.ToString().IndexOf('[') > 1) + if (s == ']' && sb.ToString().IndexOf('[') > 1) { // I [Motor roaring] love you! string temp = sb.ToString().Substring(0, sb.ToString().IndexOf('[') - 1).Trim(); - if (temp.Length > 0 && !Utilities.LowercaseLetters.Contains(temp[temp.Length - 1].ToString())) + if (temp.Length > 0 && !Utilities.LowercaseLetters.Contains(temp[temp.Length - 1])) lastWasBreak = true; } else diff --git a/src/Logic/SubtitleFormats/AdvancedSubStationAlpha.cs b/src/Logic/SubtitleFormats/AdvancedSubStationAlpha.cs index c4ebefce9..d50350359 100644 --- a/src/Logic/SubtitleFormats/AdvancedSubStationAlpha.cs +++ b/src/Logic/SubtitleFormats/AdvancedSubStationAlpha.cs @@ -330,7 +330,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text fSize = 20; string styleFormat = "Style: {0},{1},{2},{3},&H0300FFFF,&H00000000,&H02000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1"; - ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize.ToString(), GetSsaColorString(c))); + ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, GetSsaColorString(c))); } } diff --git a/src/Logic/SubtitleFormats/AvidStl.cs b/src/Logic/SubtitleFormats/AvidStl.cs index 885e642ad..536635126 100644 --- a/src/Logic/SubtitleFormats/AvidStl.cs +++ b/src/Logic/SubtitleFormats/AvidStl.cs @@ -98,7 +98,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats fs.Write(buffer, 0, buffer.Length); for (int i = 0; i < 0xde; i++) fs.WriteByte(0); - string numberOfLines = subtitle.Paragraphs.Count.ToString().PadLeft(5, '0'); + string numberOfLines = subtitle.Paragraphs.Count.ToString("D5"); buffer = Encoding.ASCII.GetBytes(numberOfLines + numberOfLines + "001"); fs.Write(buffer, 0, buffer.Length); diff --git a/src/Logic/SubtitleFormats/CaptionsInc.cs b/src/Logic/SubtitleFormats/CaptionsInc.cs index 96080e176..15286953a 100644 --- a/src/Logic/SubtitleFormats/CaptionsInc.cs +++ b/src/Logic/SubtitleFormats/CaptionsInc.cs @@ -65,7 +65,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats foreach (string line in lines) { foreach (char ch in line) - text.Add(Encoding.GetEncoding(1252).GetBytes(ch.ToString())[0]); + text.Add(Encoding.GetEncoding(1252).GetBytes(new[] { ch })[0]); // new line //text.Add(0x14); // y? 0x14 was lower!? 0x17 is higher??? 12=little top 11=top, 13=most buttom?, 15=little over middle diff --git a/src/Logic/SubtitleFormats/Cavena890.cs b/src/Logic/SubtitleFormats/Cavena890.cs index 7877e66ca..4277fd5cd 100644 --- a/src/Logic/SubtitleFormats/Cavena890.cs +++ b/src/Logic/SubtitleFormats/Cavena890.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; @@ -360,14 +361,14 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats int index = 0; for (int i = 0; i < text.Length; i++) { - string current = text.Substring(i, 1); + var current = text[i]; if (skipCount > 0) { skipCount--; } else if (languageId == LanguageIdHebrew) { - int letterIndex = _hebrewLetters.IndexOf(current); + int letterIndex = _hebrewLetters.IndexOf(current.ToString(CultureInfo.InvariantCulture)); if (letterIndex >= 0) { buffer[index] = (byte)_hebrewCodes[letterIndex]; @@ -384,7 +385,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - buffer[index] = encoding.GetBytes(current)[0]; + buffer[index] = encoding.GetBytes(new[] { current })[0]; } index++; } @@ -405,12 +406,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - byte[] b = encoding.GetBytes(current); - for (int f = 0; f < b.Length; f++) - { - buffer[index] = b[f]; - index++; - } + buffer[index] = encoding.GetBytes(new[] { current })[0]; + index++; } } } @@ -418,49 +415,49 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats { if (index < 50) { - if (current == "æ") + if (current == 'æ') buffer[index] = 0x1B; - else if (current == "ø") + else if (current == 'ø') buffer[index] = 0x1C; - else if (current == "å") + else if (current == 'å') buffer[index] = 0x1D; - else if (current == "Æ") + else if (current == 'Æ') buffer[index] = 0x5B; - else if (current == "Ø") + else if (current == 'Ø') buffer[index] = 0x5C; - else if (current == "Å") + else if (current == 'Å') buffer[index] = 0x5D; - else if (current == "Ä") + else if (current == 'Ä') { buffer[index] = 0x86; index++; buffer[index] = 0x41; } - else if (current == "ä") + else if (current == 'ä') { buffer[index] = 0x86; index++; buffer[index] = 0x61; } - else if (current == "Ö") + else if (current == 'Ö') { buffer[index] = 0x86; index++; buffer[index] = 0x4F; } - else if (current == "ö") + else if (current == 'ö') { buffer[index] = 0x86; index++; buffer[index] = 0x6F; } - else if (current == "å") + else if (current == 'å') { buffer[index] = 0x8C; index++; buffer[index] = 0x61; } - else if (current == "Å") + else if (current == 'Å') { buffer[index] = 0x8C; index++; @@ -468,85 +465,85 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } // ăĂ îÎ şŞ ţŢ â (romanian) - else if (current == "ă") + else if (current == 'ă') { buffer[index] = 0x89; index++; buffer[index] = 0x61; } - else if (current == "Ă") + else if (current == 'Ă') { buffer[index] = 0x89; index++; buffer[index] = 0x41; } - else if (current == "î") + else if (current == 'î') { buffer[index] = 0x83; index++; buffer[index] = 0x69; } - else if (current == "Î") + else if (current == 'Î') { buffer[index] = 0x83; index++; buffer[index] = 0x49; } - else if (current == "ş") + else if (current == 'ş') { buffer[index] = 0x87; index++; buffer[index] = 0x73; } - else if (current == "Ş") + else if (current == 'Ş') { buffer[index] = 0x87; index++; buffer[index] = 0x53; } - else if (current == "ţ") + else if (current == 'ţ') { buffer[index] = 0x87; index++; buffer[index] = 0x74; } - else if (current == "Ţ") + else if (current == 'Ţ') { buffer[index] = 0x87; index++; buffer[index] = 0x74; } - else if (current == "â") + else if (current == 'â') { buffer[index] = 0x83; index++; buffer[index] = 0x61; } - else if (current == "Â") + else if (current == 'Â') { buffer[index] = 0x83; index++; buffer[index] = 0x41; } - else if (current == "è") + else if (current == 'è') { buffer[index] = 0x81; index++; buffer[index] = 0x65; } - else if (current == "é") + else if (current == 'é') { buffer[index] = 0x82; index++; buffer[index] = 0x65; } - else if (current == "É") + else if (current == 'É') { buffer[index] = 0x82; index++; buffer[index] = 0x45; } - else if (current == "È") + else if (current == 'È') { buffer[index] = 0x81; index++; @@ -564,7 +561,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - buffer[index] = encoding.GetBytes(current)[0]; + buffer[index] = encoding.GetBytes(new[] { current })[0]; } index++; } diff --git a/src/Logic/SubtitleFormats/CheetahCaption.cs b/src/Logic/SubtitleFormats/CheetahCaption.cs index 94614d6d2..c55d4ff77 100644 --- a/src/Logic/SubtitleFormats/CheetahCaption.cs +++ b/src/Logic/SubtitleFormats/CheetahCaption.cs @@ -162,7 +162,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats if (idx >= 0) textBytes.Add((byte)LatinCodes[idx]); else - textBytes.Add(Encoding.GetEncoding(1252).GetBytes(text.Substring(j, 1))[0]); + textBytes.Add(Encoding.GetEncoding(1252).GetBytes(new[] { text[j] })[0]); j++; } diff --git a/src/Logic/SubtitleFormats/Csv3.cs b/src/Logic/SubtitleFormats/Csv3.cs index c9d7483ba..5d9706b59 100644 --- a/src/Logic/SubtitleFormats/Csv3.cs +++ b/src/Logic/SubtitleFormats/Csv3.cs @@ -138,12 +138,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats bool isBreak = false; for (int i = 0; i < csv.Length; i++) { - string s = csv.Substring(i, 1); - if (s == "\"" && csv.Substring(i).StartsWith("\"\"")) + var s = csv[i]; + if (s == '"' && csv.Substring(i).StartsWith("\"\"")) { sb.Append('"'); } - else if (s == "\"") + else if (s == '"') { if (isBreak) { @@ -160,10 +160,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - if (isBreak && s == " ") + if (isBreak && s == ' ') { } - else if (isBreak && s == ",") + else if (isBreak && s == ',') { sb.Append(Environment.NewLine); } diff --git a/src/Logic/SubtitleFormats/DCSubtitle.cs b/src/Logic/SubtitleFormats/DCSubtitle.cs index f713e465f..609f893d9 100644 --- a/src/Logic/SubtitleFormats/DCSubtitle.cs +++ b/src/Logic/SubtitleFormats/DCSubtitle.cs @@ -336,7 +336,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - txt.Append(line.Substring(i, 1)); + txt.Append(line[i]); } i++; } diff --git a/src/Logic/SubtitleFormats/DCinemaSmpte2007.cs b/src/Logic/SubtitleFormats/DCinemaSmpte2007.cs index 41802ff5b..36d82c871 100644 --- a/src/Logic/SubtitleFormats/DCinemaSmpte2007.cs +++ b/src/Logic/SubtitleFormats/DCinemaSmpte2007.cs @@ -137,7 +137,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) - ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid().ToString(); + ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; @@ -354,7 +354,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - txt.Append(line.Substring(i, 1)); + txt.Append(line[i]); } i++; } diff --git a/src/Logic/SubtitleFormats/DCinemaSmpte2010.cs b/src/Logic/SubtitleFormats/DCinemaSmpte2010.cs index 87169c8ce..7d5149dc7 100644 --- a/src/Logic/SubtitleFormats/DCinemaSmpte2010.cs +++ b/src/Logic/SubtitleFormats/DCinemaSmpte2010.cs @@ -137,7 +137,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) - ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid().ToString(); + ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; @@ -354,7 +354,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } else { - txt.Append(line.Substring(i, 1)); + txt.Append(line[i]); } i++; } diff --git a/src/Logic/SubtitleFormats/DvdStudioPro.cs b/src/Logic/SubtitleFormats/DvdStudioPro.cs index 8d7ec5c5b..a01be6e83 100644 --- a/src/Logic/SubtitleFormats/DvdStudioPro.cs +++ b/src/Logic/SubtitleFormats/DvdStudioPro.cs @@ -133,7 +133,7 @@ $HorzAlign = Center } else { - sb.Append(text.Substring(i, 1)); + sb.Append(text[i]); } } } diff --git a/src/Logic/SubtitleFormats/Ebu.cs b/src/Logic/SubtitleFormats/Ebu.cs index 9556cff21..22ecfea1a 100644 --- a/src/Logic/SubtitleFormats/Ebu.cs +++ b/src/Logic/SubtitleFormats/Ebu.cs @@ -348,7 +348,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats List indexOfEmdash = new List(); for (int j = 0; j < TextField.Length; j++) { - if (TextField.Substring(j, 1) == "–") + if (TextField[j] == '–') indexOfEmdash.Add(j); } @@ -476,10 +476,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats return; var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); - header.TotalNumberOfSubtitles = (subtitle.Paragraphs.Count.ToString()).PadLeft(5, '0'); // seems to be 1 higher than actual number of subtitles + header.TotalNumberOfSubtitles = subtitle.Paragraphs.Count.ToString("D5"); // seems to be 1 higher than actual number of subtitles header.TotalNumberOfTextAndTimingInformationBlocks = header.TotalNumberOfSubtitles; - string today = string.Format("{0}{1:00}{2:00}", DateTime.Now.Year.ToString().Remove(0, 2), DateTime.Now.Month, DateTime.Now.Day); + var today = string.Format("{0:yyMMdd}", DateTime.Now); if (today.Length == 6) { header.CreationDate = today; @@ -690,7 +690,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats switch (buffer[index]) { case 0xc1: // Grave - skipNext = "AEIOUaeiou".Contains(next); + skipNext = @"AEIOUaeiou".Contains(next); switch (next) { case "A": return "À"; @@ -706,7 +706,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc2: // Acute - skipNext = "ACEILNORSUYZacegilnorsuyz".Contains(next); + skipNext = @"ACEILNORSUYZacegilnorsuyz".Contains(next); switch (next) { case "A": return "Á"; @@ -737,7 +737,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc3: // Circumflex - skipNext = "ACEGHIJOSUWYaceghijosuwy".Contains(next); + skipNext = @"ACEGHIJOSUWYaceghijosuwy".Contains(next); switch (next) { case "A": return "Â"; @@ -767,7 +767,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc4: // Tilde - skipNext = "AINOUainou".Contains(next); + skipNext = @"AINOUainou".Contains(next); switch (next) { case "A": return "Ã"; @@ -783,7 +783,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc5: // Macron - skipNext = "AEIOUaeiou".Contains(next); + skipNext = @"AEIOUaeiou".Contains(next); switch (next) { case "A": return "Ā"; @@ -799,7 +799,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc6: // Breve - skipNext = "AGUagu".Contains(next); + skipNext = @"AGUagu".Contains(next); switch (next) { case "A": return "Ă"; @@ -811,7 +811,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc7: // Dot - skipNext = "CEGIZcegiz".Contains(next); + skipNext = @"CEGIZcegiz".Contains(next); switch (next) { case "C": return "Ċ"; @@ -827,7 +827,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xc8: // Umlaut or diæresis - skipNext = "AEIOUYaeiouy".Contains(next); + skipNext = @"AEIOUYaeiouy".Contains(next); switch (next) { case "A": return "Ä"; @@ -845,7 +845,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xca: // Ring - skipNext = "AUau".Contains(next); + skipNext = @"AUau".Contains(next); switch (next) { case "A": return "Å"; @@ -855,7 +855,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xcb: // Cedilla - skipNext = "CGKLNRSTcklnrst".Contains(next); + skipNext = @"CGKLNRSTcklnrst".Contains(next); switch (next) { case "C": return "Ç"; @@ -876,7 +876,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xcd: // DoubleAcute - skipNext = "OUou".Contains(next); + skipNext = @"OUou".Contains(next); switch (next) { case "O": return "Ő"; @@ -886,7 +886,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xce: // Ogonek - skipNext = "AEIUaeiu".Contains(next); + skipNext = @"AEIUaeiu".Contains(next); switch (next) { case "A": return "Ą"; @@ -900,7 +900,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats } return string.Empty; case 0xcf: // Caron - skipNext = "CDELNRSTZcdelnrstz".Contains(next); + skipNext = @"CDELNRSTZcdelnrstz".Contains(next); switch (next) { case "C": return "Č"; diff --git a/src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs b/src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs index 80a90ca53..fa8d75de8 100644 --- a/src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs +++ b/src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs @@ -84,7 +84,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats "" + Environment.NewLine + "" + Environment.NewLine + " " + Environment.NewLine + - " EC466A7D-8B45-4682-9978-D15D630C882Eadd" + seString + "" + duration.ToString() + ">" + GetNtsc() + @"" + GetFrameRateAsString() + @"" + GetNtsc() + @"" + GetFrameRateAsString() + @"01:00:00:0090000sourceNDF-1-1"; diff --git a/src/Logic/SubtitleFormats/FinalCutProTextXml.cs b/src/Logic/SubtitleFormats/FinalCutProTextXml.cs index e0873e592..fb85227d1 100644 --- a/src/Logic/SubtitleFormats/FinalCutProTextXml.cs +++ b/src/Logic/SubtitleFormats/FinalCutProTextXml.cs @@ -86,7 +86,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats @" 5B3B0C07-9A9D-42AA-872C-C953923F97D8 add X - " + duration.ToString() + @" + " + duration + @" " + GetNtsc() + @" " + GetFrameRateAsString() + @" @@ -102,7 +102,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats NDF 0 - " + duration.ToString() + @" + " + duration + @"