Skip to content
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

Update TXT.php #28629

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
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
6 changes: 6 additions & 0 deletions lib/private/Preview/TXT.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
if (trim($content) === '') {
return null;
}

$encoding = mb_detect_encoding($content . 'a', 'SJIS-win, GB2312, GBK, UTF-8, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII', true);
if ($encoding === '') {
$encoding = 'ISO-8859-1';
}
MasahikoSada marked this conversation as resolved.
Show resolved Hide resolved
$content = iconv($encoding, 'UTF-8', $content);
MasahikoSada marked this conversation as resolved.
Show resolved Hide resolved

$lines = preg_split("/\r\n|\n|\r/", $content);

Expand Down