I need to support an old site. using HTML4,
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" >
and DB TABLE fields with latin1_swedish_ci
collation.
in PHP code, when connecting to DB, always use set names 'latin1'
Recently, the site host updated to PHP 7.4. Since this update, the France accent letters are not displayed well.
In FireFox console there is the following error:
The byte stream was erroneous according to the character encoding that was declared. The character encoding declaration may be incorrect.
According to cPanel and phpinfo() I now have:
I guess the error is because I send windows-1252 and receive UTF-8...
I know that the correct solution is to use UTF-8 in the DB and in the meta TAG.
but is there a way for the short run to display all pages in the correct charset?
EDIT: Is there a way to show "latin" encoding when PHP forces me to deliver UTF8? e.g. to disable the PHP forcing, or to convert "latin" strings to UTF8, ...
I started replacing a test TABLE to UTF8, but then realizesed it was not necessary. I can keep using the same DB, but in my site pages I must make some changes:
in the HTML, use <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
instead of <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" >
in the PHP, use set names utf8
instead of set names latin1