How to configure encoding in multiple languages?

Make a website on OpenServer, which is on the page you can switch to display texts in several languages (French, English and Russian). In the database, the browser is everywhere UTF-8. All perfectly displayed.

Moved to protest the hosting and then the problems started. French texts do not display special characters (such as à or é), and Russian text at all displayed in gibberish. Began to understand, like from a DB everything is in UTF-8 .htaccess just in case, also prescribed...

But almost inadvertently changed the title
header("Content-type: text/html; charset=windows-1251");

and the Russian text is displayed. But the French characters are all also issues...

Prompt in what side to dig?
March 19th 20 at 09:07
1 answer
March 19th 20 at 09:09
Solution
To configure encoding for all languages is very simple. In the database and the browser all need to stand in UTF-8. Not in imagination, but in reality:

Table in database is created with charset=utf8
- DB connection in PHP should set the encoding utf8 (with dedicated functions)
- The web server when the response needs to give the Content-type header with charset=UTF-8
And why on the LAN all the rules displayed? - Bartholome.Stiedemann commented on March 19th 20 at 09:12
because of a cockroach deep feet - maye33 commented on March 19th 20 at 09:15
Now looked through the lyrics and then where I imported them to the database not hammered by hand in the database everything is displayed normally. So I'm somewhere in the texts made in the encoding windows-1251.

But as in the LAN this is not noticeable, how do I track this now? I.e. how do I know that I have added text in the database not in windows-1251 and UTF-8.

I apologize in advance for stupid questions. - Bartholome.Stiedemann commented on March 19th 20 at 09:18
To configure encoding for all languages is very simple. In the database and the browser all need to stand in UTF-8. Not in imagination, but in reality:

Table in database is created with charset=utf8
- DB connection in PHP should set the encoding utf8 (with dedicated functions)
- The web server when the response needs to give the Content-type header with charset=UTF-8 - maye33 commented on March 19th 20 at 09:21
It is clear, I a moment can not understand. If my database encoding is UTF-8. I go in through phpMyAdmin and make the text in a different encoding. In this case, what will happen? - Bartholome.Stiedemann commented on March 19th 20 at 09:24
nothing. using phpMyAdmin, you cannot make the text "in a different encoding". - maye33 commented on March 19th 20 at 09:27
phpMyAdmin is always displayed in utf-8 and always tells the database that data will be in this encoding. so if the database is configured correctly, then there just will not be able to get data in wrong encoding - maye33 commented on March 19th 20 at 09:30
You yourself wrote the first message:

"data recorded in 1251, while encoding is on the tables UTF 8"

How is this possible? - Bartholome.Stiedemann commented on March 19th 20 at 09:33
I deleted this comment because it's not the only reason. or maybe it's because it is not specified or incorrectly specified encoding connection
in General, the question "why and what" has no practical meaning.
you just have to be done once correctly and it will work - maye33 commented on March 19th 20 at 09:36
The problem was solved, and how often it happens by my carelessness. Just not inserted mysqli_set_charset($link, "utf8");

Thank you, but the question on account of the fact that the database can be texts in different from declared in the table encoding is left open... - Bartholome.Stiedemann commented on March 19th 20 at 09:39
because it is not specified or incorrectly specified encoding connection - maye33 commented on March 19th 20 at 09:42

Find more questions by tags Web Development