慕容的工作随笔

慕容的工作随笔

记录学习和工作

处理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);

评论 (0)

还没有评论,来做第一个吧。

发表评论

提交后需管理员审核通过后显示