From d0fefc6381b5647a20c3e8df2490923fcb92211a Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sat, 20 Feb 2021 18:34:07 +0100 Subject: [PATCH] Trying to fix ebu stl header issue - thx BlankProgramming :) Related to #4806 --- src/libse/SubtitleFormats/Ebu.cs | 5 ++--- src/ui/Forms/Main.cs | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libse/SubtitleFormats/Ebu.cs b/src/libse/SubtitleFormats/Ebu.cs index b42cdfe10..7fb881286 100644 --- a/src/libse/SubtitleFormats/Ebu.cs +++ b/src/libse/SubtitleFormats/Ebu.cs @@ -1037,9 +1037,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public void LoadSubtitle(Subtitle subtitle, byte[] buffer) { subtitle.Paragraphs.Clear(); - subtitle.Header = null; var header = ReadHeader(buffer); - subtitle.Header = Encoding.UTF8.GetString(buffer); + subtitle.Header = header.ToString(); Paragraph last = null; byte lastExtensionBlockNumber = 0xff; JustificationCodes = new List(); @@ -1120,7 +1119,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats return header; } - private static Encoding GetEncoding(string codePageNumber) + public static Encoding GetEncoding(string codePageNumber) { try { diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index dad728223..1d0f120a3 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -28439,7 +28439,9 @@ namespace Nikse.SubtitleEdit.Forms { if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) { - var header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); + var encoding = Ebu.GetEncoding(_subtitle.Header.Substring(0, 3)); + var buffer = encoding.GetBytes(_subtitle.Header); + var header = Ebu.ReadHeader(buffer); properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle); } else