其他分享
首页 > 其他分享> > NextCloud上传txt文本文件,中文内容乱码。

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

标签:UTF,encoding,fileContents,乱码,8859,ISO,file,txt,NextCloud
来源: https://blog.csdn.net/smxalong/article/details/104754170