【发布时间】:2021-09-26 14:51:13
【问题描述】:
我正在尝试将我的网站从 windows-1251 更改为 utf-8,但它不会让步。
网络上有很多“解决方案”,但似乎还不够。
这是我所做的:
-
我将 index.html(智能模板)和 index.php 文件的编码更改为 UTF-8。
-
我设置
<html lang="ru"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
在 index.html 中
-
我设置
header('Content-type: text/html; charset=utf-8');
在 index.php 的几个地方
-
我变了
default_charset="UTF-8"
在 php.ini 中并重新启动我的 Apache(XAMPP) 服务器
Chrome 开发工具仍然说我的页面是“Content-Type: text/html; charset=windows-1251”,我在浏览器中看到的是乱码而不是西里尔字母。
我还能做什么?
附:我的 index.html 现在看起来像这样:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Тест
</body>
</html>
我直接通过浏览器打开它:http://localhost:8080/index.html
【问题讨论】:
标签: php encoding utf-8 cyrillic charset