Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
INT. PALO TORCIDO HIGH SCHOOL, CAFETER�A - DAY
嗨,我上传了一个 .txt 到我的服务器,并使用 fopen/fread 获取了内容,并且也没有使用 file_get_contents 以防万一。
我似乎无法弄清楚如何编码特殊字符......
在我的 HTML 中,我将 UTF 设置为 8。我还尝试了一个 PHP HEADER 来使用 UTF-8 编码。
处理不属于英文字母的字母的文件的正确方法是什么?
试试 utf8_encode()
echo utf8_encode(file_get_contents('file.txt'));
如果 *.txt 以 Latin1 编码,则此方法有效。如果也可以使用其他编码,请使用 mb_detect_encoding() 检测编码并使用 mb_convert_encoding() 将其编码为 UTF8