I am absolutely stuck.
I have an old website that was running on PHP4 and MySQL4. The SQL data contains slovak special characters (á, š, ť, ľ, ž etc.). The old site displays the characters fine.
I've migrated the site to a new host, it is now running on PHP 7.3 and MariaDB 10.3. I have replaced deprecated mysql_ functions with MySQLi and now the code runs fine. However, the characters are completely messed up.
I've came across multiple questions and answers, here's what I've tried:
Setting charset to utf8 and/or windows-1250 to mysqli connection
$link->set_charset("utf8mb4"); mysqli_set_charset($mysqli, "utf8");
Setting both utf8 and/or windows-1250 headers to every .php file
header('Content-Type: text/html; charset=utf-8');
Re-saving each file manually with UTF8 and/or windows-1250 encoding using Sublime text
Changing database collation to utf8_unicode_ci, utf8_slovak_ci and also something else
Altering character sets of all tables and database
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci; ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Manually converting the output from UTF8 to windows-1250 using PHP's iconv (this messed up the output even more)
$output = iconv( "Windows-1250", "UTF-8", ($output));
Tried different collations when importing the old database. Also tried with and without MYSQL40 import compatibility mode in phpMyAdmin
Setting both utf8 and/or windows-1250 html meta charsets
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <meta charset="UTF-8">
Something that I've discovered. When I read the SQL data directly in phpMyAdmin, it displays the exact same data with messed up encoding in both old database (mysql4) and a new one. However, the old site somehow displays it correctly on the front-end.
I am really stuck, I really think I've tried every solution. What might be the problem?