Fix "reverse rtl" issue with music symbols - thx OmrSi :)

See 5a5300583a (commitcomment-33215599)
This commit is contained in:
niksedk 2019-04-21 07:40:33 +02:00
parent f7dd5dadca
commit ef6f074923
2 changed files with 38 additions and 0 deletions

View File

@ -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("<i>", StringComparison.Ordinal) ||
s2.StartsWith("<b>", StringComparison.Ordinal) ||
s2.StartsWith("<u>", 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("</i>", StringComparison.Ordinal) ||
s2.EndsWith("</b>", StringComparison.Ordinal) ||
s2.EndsWith("</u>", StringComparison.Ordinal))

View File

@ -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);
}
}
}