diff --git a/libse/Utilities.cs b/libse/Utilities.cs index 859edb6dd..d309b25c4 100644 --- a/libse/Utilities.cs +++ b/libse/Utilities.cs @@ -1450,6 +1450,18 @@ namespace Nikse.SubtitleEdit.Core string postTags = string.Empty; for (int k = 0; k < 10; k++) { + if (s2.StartsWith("♪ ", StringComparison.Ordinal) || + s2.StartsWith("♫ ", StringComparison.Ordinal)) + { + preTags.Append(s2.Substring(0, 2)); + s2 = s2.Remove(0, 2); + } + if (s2.StartsWith("♪", StringComparison.Ordinal) || + s2.StartsWith("♫", StringComparison.Ordinal)) + { + preTags.Append(s2.Substring(0, 1)); + s2 = s2.Remove(0, 1); + } if (s2.StartsWith("", StringComparison.Ordinal) || s2.StartsWith("", StringComparison.Ordinal) || s2.StartsWith("", StringComparison.Ordinal)) @@ -1465,6 +1477,18 @@ namespace Nikse.SubtitleEdit.Core s2 = s2.Remove(0, idx); } + if (s2.EndsWith(" ♪", StringComparison.Ordinal) || + s2.EndsWith(" ♫", StringComparison.Ordinal)) + { + postTags = s2.Substring(s2.Length - 2) + postTags; + s2 = s2.Remove(s2.Length - 2); + } + if (s2.EndsWith("♪", StringComparison.Ordinal) || + s2.EndsWith("♫", StringComparison.Ordinal)) + { + postTags = s2.Substring(s2.Length - 1) + postTags; + s2 = s2.Remove(s2.Length - 1); + } if (s2.EndsWith("", StringComparison.Ordinal) || s2.EndsWith("", StringComparison.Ordinal) || s2.EndsWith("", StringComparison.Ordinal)) diff --git a/src/Test/Logic/UtilitiesTest.cs b/src/Test/Logic/UtilitiesTest.cs index ea2a40af7..b3cbbe36c 100644 --- a/src/Test/Logic/UtilitiesTest.cs +++ b/src/Test/Logic/UtilitiesTest.cs @@ -737,5 +737,19 @@ namespace Test.Logic var result = Utilities.ReverseStartAndEndingForRightToLeft("\"Hey." + Environment.NewLine + "Hey.\""); Assert.AreEqual(".Hey\"" + Environment.NewLine + "\".Hey", result); } + + [TestMethod] + public void ReverseStartAndEndingForRightToLeftMusicSymbols() + { + var result = Utilities.ReverseStartAndEndingForRightToLeft("♪ Hey... ♪"); + Assert.AreEqual("♪ ...Hey ♪", result); + } + + [TestMethod] + public void ReverseStartAndEndingForRightToLeftMusicSymbols2() + { + var result = Utilities.ReverseStartAndEndingForRightToLeft("♫Hey...♫"); + Assert.AreEqual("♫...Hey♫", result); + } } }