The situation is this: I started creating pages for the site. The default encoding was
Windows-1251, and the database was
UTF-8. Then I recoded the pages to
BOM. At the moment, the database settings are:
MySQL connection collation: utf8_general_ci MySQL - Server: localhost via TCP/IP - Server version: 5.1.40-community - Protocol version: 10 - User: [email protected] - MySQL charset: UTF-8 Unicode (utf8) Web server - Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8k PHP/5.3.3 - MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $ - PHP extension: mysql
And in the end: information from the database is displayed correctly, but what was written on the pages themselves is visible only when you set the encoding in the browser to
Accordingly, what was deduced from the base will be on krakozyabra. Tell me how to solve?
Answer 1, authority 100%
at the beginning of the file
header('Content-type: text/html; charset=utf-8');
immediately after connecting to the database
mysql_query('SET NAMES utf8');
for sure )
Answer 2, authority 50%
In the end it only helped
mysql_query(‘SET NAMES utf8’);
Something seems to me that the html files that display info and bases have
Windows-1251encoding. Meta can have
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
, but the characters themselves are encoded in
Windows-1251. To check, try opening, for example, in
AkelPadthe problematic page encoded
UTF-8. If the Russian text is not normal, then re-save in
Add these lines to .htaccess
AddCharset utf-8 .php .html .js AddDefaultCharset off
You threw it into the root folder and it doesn’t work? Is it local or global?
In general, if it’s on Denver, what I wrote initially usually solves all problems… So x3… go to php.ini and change the default encoding there…
“When you set the encoding in the browser to Windows-1251” people, if it reads norms in win1251, then infa is actually written in win1251… most likely the problem is that infa is in your database in win1251, even though you are a charset they put down the utf one there … how did you enter the information into the database?
Dump the database without compression and change the encoding with notepad. It seems to me once such a ride. ) Well, at least try…
Open in notepad, look at the encoding of the dump. Change to utf if there is wine1251.
Did you forget to change the encoding of the files with the static server to UTF-8? Just don’t confuse it with the
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">parameter! It’s a little different!