Answer the question
In order to leave comments, you need to log in
What encoding to use?
Hello.
Tired of coding.
In the database, the Russian text looks like this:
Ðлебарда Ñурвилурга
Data is entered into the database using a PHP script:
1. The file encoding is set to UTF-8
2. There is this line at the beginning of the file: header('Content-type: text/html; charset=windows-1251');
3. The script reads the html of the remote page on which the default encoding is windows-1251.
4. After reading the remote html code of the page, this code is converted: $page = iconv("windows-1251", "utf-8", $page);
5. In mysql, both the table and string fields are set to utf-8_general_ci encoding.
I screwed up with the encoding.
No matter how I play with encodings, I have not yet received a normal result.
I will be glad to help knowledgeable people.
Answer the question
In order to leave comments, you need to log in
Resolved by adding the highlighted part:
$pdo = new PDO("mysql:dbname=$DBName;host=$DBHost ;charset=UTF8 ", $DBUser, $DBPass);
2nd paragraph write like this:header('Content-type: text/html; charset=utf-8');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question