Trying to fix ebu stl header issue - thx BlankProgramming :)

Related to #4806
This commit is contained in:
Nikolaj Olsson 2021-02-20 18:34:07 +01:00
parent cb5102be43
commit d0fefc6381
2 changed files with 5 additions and 4 deletions

View File

@ -1037,9 +1037,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public void LoadSubtitle(Subtitle subtitle, byte[] buffer) public void LoadSubtitle(Subtitle subtitle, byte[] buffer)
{ {
subtitle.Paragraphs.Clear(); subtitle.Paragraphs.Clear();
subtitle.Header = null;
var header = ReadHeader(buffer); var header = ReadHeader(buffer);
subtitle.Header = Encoding.UTF8.GetString(buffer); subtitle.Header = header.ToString();
Paragraph last = null; Paragraph last = null;
byte lastExtensionBlockNumber = 0xff; byte lastExtensionBlockNumber = 0xff;
JustificationCodes = new List<int>(); JustificationCodes = new List<int>();
@ -1120,7 +1119,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return header; return header;
} }
private static Encoding GetEncoding(string codePageNumber) public static Encoding GetEncoding(string codePageNumber)
{ {
try try
{ {

View File

@ -28439,7 +28439,9 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) 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); properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle);
} }
else else