From 60734bbca2077773fcc245d6b3a3d8da3f57c4e0 Mon Sep 17 00:00:00 2001 From: Waldi Ravens Date: Thu, 10 Dec 2015 06:20:30 +0100 Subject: [PATCH] Minor fix (Forms/VobSubOcr) The subtitle paragraph text cannot be part of a composite format string, because it might contain curly brackets. --- src/Forms/VobSubOcr.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Forms/VobSubOcr.cs b/src/Forms/VobSubOcr.cs index 6e69b60a5..2a01e1a0d 100644 --- a/src/Forms/VobSubOcr.cs +++ b/src/Forms/VobSubOcr.cs @@ -7524,34 +7524,35 @@ namespace Nikse.SubtitleEdit.Forms progressBar1.Value = 0; progressBar1.Visible = true; int imagesSavedCount = 0; - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.AppendLine(""); sb.AppendLine("Subtitle images"); sb.AppendLine(""); for (int i = 0; i < _subtitle.Paragraphs.Count; i++) { progressBar1.Value = i; - Bitmap bmp = GetSubtitleBitmap(i); - string numberString = string.Format("{0:0000}", i + 1); + var bmp = GetSubtitleBitmap(i); if (bmp != null) { - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + ".png"); - bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); + var fileName = string.Format(CultureInfo.InvariantCulture, "{0:0000}.png", i + 1); + var filePath = Path.Combine(folderBrowserDialog1.SelectedPath, fileName); + bmp.Save(filePath, System.Drawing.Imaging.ImageFormat.Png); imagesSavedCount++; - Paragraph p = _subtitle.Paragraphs[i]; - string text = string.Empty; + var p = _subtitle.Paragraphs[i]; + sb.AppendFormat(CultureInfo.InvariantCulture, "#{3}:{0}->{1}
", p.StartTime.ToShortString(), p.EndTime.ToShortString(), fileName, i + 1); if (!string.IsNullOrEmpty(p.Text)) { - string backgroundColor = System.Drawing.ColorTranslator.ToHtml(subtitleListView1.GetBackgroundColor(i)); - text = "
" + WebUtility.HtmlEncode(p.Text.Replace("", "@1__").Replace("", "@2__")).Replace("@1__", "").Replace("@2__", "").Replace(Environment.NewLine, "
") + "
"; + var backgroundColor = System.Drawing.ColorTranslator.ToHtml(subtitleListView1.GetBackgroundColor(i)); + var text = WebUtility.HtmlEncode(p.Text.Replace("", "@1__").Replace("", "@2__")).Replace("@1__", "").Replace("@2__", "").Replace(Environment.NewLine, "
"); + sb.Append("
").Append(text).Append("
"); } - sb.AppendLine(string.Format("#{3}:{0}->{1}
" + text + "


", p.StartTime.ToShortString(), p.EndTime.ToShortString(), numberString, i + 1)); + sb.AppendLine("


"); bmp.Dispose(); } } sb.AppendLine(""); sb.AppendLine(""); - string htmlFileName = Path.Combine(folderBrowserDialog1.SelectedPath, "index.html"); + var htmlFileName = Path.Combine(folderBrowserDialog1.SelectedPath, "index.html"); File.WriteAllText(htmlFileName, sb.ToString()); progressBar1.Visible = false; MessageBox.Show(string.Format("{0} images saved in {1}", imagesSavedCount, folderBrowserDialog1.SelectedPath));