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