处理NextCloud显示中文文件乱码 转

转自:https://blog.csdn.net/skydust1979/article/details/106280811/

修改/nextcloud/lib/public/AppFramework/Http/FileDisplayResponse.php文件

 

将$output->setOutput($this->file->getContent());注释掉,修改为:

$fileContents=$this->file->getContent();

$encoding = mb_detect_encoding($fileContents . "a", "UTF-8,GB2312, GBK, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII", true);

if ($encoding === "") {
$encoding = "ISO-8859-15";

}

$fileContents = iconv($encoding, "UTF-8", $fileContents);

$output->setOutput($fileContents);

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注