上传的文件内容被回显但不显示重音符号

发布于 2024-10-17 00:51:47 字数 277 浏览 6 评论 0原文

INT. PALO TORCIDO HIGH SCHOOL, CAFETER�A - DAY

您好,我将 .txt 上传到我的服务器并使用 fopen/fread 获取内容,并且还使用 file_get_contents 以防万一。

我似乎不知道如何对特殊字符进行编码...

在我的 HTML 中,我将 UTF 设置为 8。我还尝试使用 PHP HEADER 来使用 UTF-8 编码。

处理包含不属于英文字母的字母的文件的正确方法是什么?

INT. PALO TORCIDO HIGH SCHOOL, CAFETER�A - DAY

Hi, I uploaded a .txt to my server and got the contents with fopen/fread and alsot used file_get_contents just in case.

I can't seem to figure out how to encode the special characters...

In my HTML i have my UTF set to 8. I also tried a PHP HEADER to use UTF-8 encoding.

what is the proper way to handle files with letters not part of the english alphabet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2024-10-24 00:51:47

尝试 utf8_encode()

echo utf8_encode(file_get_contents('file.txt'));

如果 *.txt 采用 Latin1 编码,则此方法有效。如果也可以使用其他编码,请使用 mb_detect_encoding() 检测编码并使用 mb_convert_encoding() 将其编码为 UTF8

Try utf8_encode()

echo utf8_encode(file_get_contents('file.txt'));

This works if the *.txt is encoded in Latin1. If other encoding may be used too, detect the encoding using mb_detect_encoding() and encode it to UTF8 with mb_convert_encoding()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文