NextCloud上传txt文本文件,中文内容乱码。

修改/服务器路径/nextcloud/apps/text/lib/Service/ApiService.php文件
第112行修改为:
$fileContents=$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';
}
if ($encoding !== 'UTF-8') {
$fileContents = iconv($encoding, 'UTF-8', $fileContents);
$file->putContent($fileContents );
}
return new FileDisplayResponse($file);

发布了7 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/smxalong/article/details/104754170