0

I'm trying to change my website from windows-1251 to utf-8, but it won't budge.

There are a ton of "solutions" to this on web, but any doesn't seem to be sufficient.

Here is what I did:

  1. I changed the encoding of the index.html (smarty template) and index.php files to UTF-8.

  2. I set

     <html lang="ru">
     <head>
     <meta charset="utf-8">
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    

in index.html

  1. I set

    header('Content-type: text/html; charset=utf-8');
    

in several places in index.php

  1. I changed

    default_charset="UTF-8"
    

in php.ini and restarted my Apache(XAMPP) server

And still, the Chrome devtools say my page is "Content-Type: text/html; charset=windows-1251" and I see gibberish instead of Cyrillic in my browser.

What else can I do?

P.S. my index.html looks like this now:

<?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>

and I open it dirrectly via the browser: http://localhost:8080/index.html

4

2 回答 2

0

检查这个网址。这可能会帮助你。 字符集更改

编辑:试试这些。

  1. 在 HTML 标记之前设置标题。

    <?php header('Content-type: text/html; charset=utf-8'); ?> <!DOCTYPE html>

  2. 当您将脚本连接到数据库时,您需要为 PHP/MySQL 连接指定相同的字符集。检查 旧问题

于 2021-09-26T15:22:50.853 回答
0

看来我安装了 Chrome 编码扩展,设置为 Windows-1251:https ://chrome.google.com/webstore/detail/set-character-encoding/bpojelgakakmcfmjfilgdlmhefphglae

于 2021-09-26T16:51:19.410 回答