This commit is contained in:
Nikolaj Olsson 2019-11-14 18:16:05 +01:00
commit 42a08d8bbc
3 changed files with 32 additions and 11 deletions

View File

@ -5,12 +5,14 @@
* Teletext support (use File -> Open... choose .ts/.m2ts file) - thx HeartWare
* Auto break options "pixel width" (and not after #of characters) + "bottom heavy"
* Auto break options now available in UI via Options -> Settings -> Tools
* IMPROVED:
* Add new format psl
* Add Macedonian translation - thx Numberguy
* IMPROVED:
* Update Polish translation - thx admas
* Update Korean translation - thx domddol
* Update Bulgarian translation - thx KalinM
* Improved reading of faulty .srt files a little - thx andradadad
* Update Brazilian translation - thx igor
* Improve reading of faulty .srt files a little - thx andradadad
* Allow invert colors pre-processing for T4 - thx rookiefromspace/OmrSi
* Improve line mergning of 3+ lines - thx taxen
* Improve read speed of .ts/.m2ts files
@ -18,6 +20,9 @@
* Fix "Replace" issue - thx loyaldragon
* Fix extracting correct audio track with VLC
* Fix remove empty lines after "Multiple replace" in "Batch convert"
* Fix "Fix ocr errors" in "Fix common errors" via "Batch convert" - thx JySzE
* Fix issue with PAC reading - thx s3ncha
* Fix possible crash when going from src view to list view
3.5.11 (27th October 2019)

View File

@ -108,14 +108,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
long.TryParse(frameArray[1], NumberStyles.None, CultureInfo.InvariantCulture, out var endFrame))
{
var rtf = line.Remove(0, startText);
var text = RtfDecode(rtf, "en");
var text = RtfDecode(rtf);
subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrame), FramesToMilliseconds(endFrame)));
}
}
subtitle.Renumber();
}
private static string RtfDecode(string text, string language)
private static string RtfDecode(string text)
{
var codeOn = false;
var italicOn = false;
@ -140,27 +140,38 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else if (last == '\\')
{
if (ch == 'u' && i + 5 < text.Length && char.IsNumber(text[i + 1]) && char.IsNumber(text[i + 2]) && char.IsNumber(text[i + 3]) && char.IsNumber(text[i + 4]))
if (ch == 'u' && i + 6 < text.Length && char.IsNumber(text[i + 1]) && char.IsNumber(text[i + 2]) && char.IsNumber(text[i + 3]) && char.IsNumber(text[i + 4]) && char.IsNumber(text[i + 5]))
{
var unicodeNumber = text.Substring(i + 1, 4);
var unescaped = char.ConvertFromUtf32(int.Parse(unicodeNumber));
sb.Append(unescaped);
if (i + 7 < text.Length && text[i + 6] == ' ')
{
i++;
}
i += 5;
}
else if (ch == 'u' && i + 5 < text.Length && char.IsNumber(text[i + 1]) && char.IsNumber(text[i + 2]) && char.IsNumber(text[i + 3]) && char.IsNumber(text[i + 4]))
{
var unicodeNumber = text.Substring(i + 1, 4);
var unescaped = char.ConvertFromUtf32(int.Parse(unicodeNumber));
sb.Append(unescaped);
i += 4;
if (i + 6 < text.Length && text[i + 5] == ' ')
{
i++;
}
i += 4;
}
else if (ch == 'u' && i + 4 < text.Length && char.IsNumber(text[i + 1]) && char.IsNumber(text[i + 2]) && char.IsNumber(text[i + 3]))
{
var unicodeNumber = text.Substring(i + 1, 3);
var unescaped = char.ConvertFromUtf32(int.Parse(unicodeNumber));
sb.Append(unescaped);
i += 4;
if (i + 5 < text.Length && text[i + 4] == ' ')
{
i++;
}
i += 3;
}
else if (ch == 'i' && i + 3 < text.Length && " \r\n\\{}".Contains(text[i + 1]))
{
@ -196,7 +207,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
// start/end of block
codeOn = false;
}
else
else if (!"\r\n".Contains(ch))
{
sb.Append(ch);
}
@ -207,7 +218,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
sb.Append("</i>");
}
return Utilities.RemoveUnneededSpaces(sb.ToString(), language);
return Utilities.RemoveUnneededSpaces(sb.ToString(), string.Empty);
}
}
}

View File

@ -84,7 +84,7 @@ namespace Nikse.SubtitleEdit.Forms
private string _customTextTemplate;
private readonly DurationsBridgeGaps _bridgeGaps;
private const int ConvertMaxFileSize = 1024 * 1024 * 10; // 10 MB
private Dictionary<string, List<BluRaySupParser.PcsData>> _bdLookup =new Dictionary<string, List<BluRaySupParser.PcsData>>();
private Dictionary<string, List<BluRaySupParser.PcsData>> _bdLookup = new Dictionary<string, List<BluRaySupParser.PcsData>>();
public BatchConvert(Icon icon)
{
@ -1204,9 +1204,14 @@ namespace Nikse.SubtitleEdit.Forms
{
using (var fixCommonErrors = new FixCommonErrors { BatchMode = true })
{
var l = Configuration.Settings.Tools.BatchConvertLanguage;
if (string.IsNullOrEmpty(l))
{
l = LanguageAutoDetect.AutoDetectGoogleLanguage(p.Subtitle);
}
for (int i = 0; i < 3; i++)
{
fixCommonErrors.RunBatch(p.Subtitle, p.Format, p.Encoding, Configuration.Settings.Tools.BatchConvertLanguage);
fixCommonErrors.RunBatch(p.Subtitle, p.Format, p.Encoding, l);
p.Subtitle = fixCommonErrors.FixedSubtitle;
}
}