Skip to content

Commit

Permalink
Fix SMI decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Jan 2, 2024
1 parent 5a34c5a commit 3b83a22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Code/Converters/SmiConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function fileContentToInternalFormat($file_content, $original_file_conten
{
$internal_format = []; // array - where file content will be stored

$file_content = mb_convert_encoding($file_content, 'HTML-ENTITIES', "UTF-8");
if (strpos($file_content, '</SYNC>') === false) {
$file_content = str_replace('<SYNC ', '</SYNC><SYNC ', $file_content);
}
Expand Down
16 changes: 16 additions & 0 deletions tests/formats/SmiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ public function testClientFile2()
$this->assertInternalFormatsEqual($expected, $actual);
}

public function testNonEnglishWords()
{
$actual = Subtitles::loadFromString('
<SAMI>
<BODY>
<SYNC Start=0><P Class=ENUSCC>늘</P></SYNC>
<SYNC Start=140400><P Class=ENUSCC>&nbsp;</P></SYNC>
</BODY>
</SAMI>
')->getInternalFormat();
$expected = (new Subtitles())
->add(0, 140.4, '')
->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual);
}

// ---------------------------------- private ----------------------------------------------------------------------

private static function fileContent()
Expand Down

0 comments on commit 3b83a22

Please sign in to comment.