no message

This commit is contained in:
hellcat 2025-12-18 18:08:37 +08:00
parent 82e372fc3b
commit 3325fedf1d

View File

@ -188,7 +188,8 @@ final class FreenodeCrawl
// $sFileContent = base64_decode($sFileContent);
// }
file_put_contents($sPath, $sFileContent);
// file_put_contents($sPath, $sFileContent);
self::save_utf8_file($sPath, $sFileContent);
self::fileRealUpd($aFrom["id"], $sType, $sFileName);
@ -232,4 +233,24 @@ final class FreenodeCrawl
return $sContent;
}
private static function save_utf8_file($filename, $content) {
// 自动检测编码
$encoding = mb_detect_encoding(
$content,
['UTF-8', 'GBK', 'BIG5', 'ISO-8859-1'],
true
);
// 如果不是 UTF-8就转成 UTF-8
if ($encoding !== 'UTF-8') {
$content = mb_convert_encoding($content, 'UTF-8', $encoding);
}
// 确保文件头是 UTF-8可选
// $content = "\xEF\xBB\xBF" . $content; // 如果需要 BOM可以加上
return file_put_contents($filename, $content) !== false;
}
}