8000 simple toString method by scottf-tvw · Pull Request #66 · captioning/captioning · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

simple toString method #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
8000
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Captioning/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,30 @@ public function save($filename = null, $writeBOM = false)
throw new \Exception('Unable to save the file.');
}
}
/**
* returns string of vtt
*
* @param bool $writeBOM
*/
public function toString($writeBOM = false){
if (trim($this->fileContent) == '') {
$this->build();
}

$file_content = $this->fileContent;
if (strtolower($this->encoding) != 'utf-8') {
if ($this->useIconv) {
$file_content = iconv('UTF-8', $this->encoding, $file_content);
} else {
$file_content = mb_convert_encoding($file_content, $this->encoding, 'UTF-8');
}
}

if ($writeBOM) {
$file_content = "\xef\xbb\xbf".$file_content;
}
return $file_content;
}

/**
* Computes reading speed statistics
Expand Down
2 changes: 1 addition & 1 deletion src/Captioning/Format/WebvttFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function parse()
++$i;
} while (($line = $this->getNextValueFromArray($fileContentArray)) !== false);

if (count($parsing_errors) > 0) {
if (count($parsing_errors) > 1) {
throw new \Exception('The following errors were found while parsing the file:'."\n".print_r($parsing_errors, true));
}

Expand Down
0