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

klm123
  • 12,105
  • 14
  • 57
  • 95

2 Answers2

0

Check this url. This might help you. charset changing

Edit: Try these.

  1. Set the header before HTML tags.

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

  2. when you connect your script to the database you need to specify the same character set for PHP/MySQL connection. Check Old issue

Fc0001
  • 58
  • 12
0

It appeared I had a Chrome encoding extension installed, which was set to Windows-1251: https://chrome.google.com/webstore/detail/set-character-encoding/bpojelgakakmcfmjfilgdlmhefphglae

klm123
  • 12,105
  • 14
  • 57
  • 95
  • 1
    So one workaround which you didn't consider was: use a different client (web browser). Maybe you even encounter one that already comes with the possibility to let the user choose the encoding - maybe _Safari_ still allows this... – AmigoJack Oct 16 '21 at 07:03