phpencodingutf-8cyrilliccharset

Content-Type charset won't change


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


Solution

  • 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