Answer the question
In order to leave comments, you need to log in
How to fix encoding issues when migrating data from an old site?
There is an old site X1 (self-written online store), and a new site X2 (online store on wooCommerce). Both sites have the same database encoding parameters:
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
When you try to transfer data from X1 to X2, all Russian text turns into "???????-?????? ????". When transferring data from X2 to X1, the entire Russian text becomes "Санкт-Петербург".
Using the service 2cyr.com/decodeI found out that on the old X2 site, all data is stored in utf8, but it is displayed as win-1251. On the new one, everything is standard like WordPress.
Question: How can I organize the correct reading of data, converting, and then saving?
Answer the question
In order to leave comments, you need to log in
Found a solution to the problem. When reading data from the first database, I set the data encoding:
Then I convert the received data to UTF8 using iconv
When writing to the first database, it is enough to convert the data to cp1251 using iconv
In addition to checking the dump encoding, you can look towards Apache.
Perhaps the encoding in its settings does not match yours, which causes the display problem, but everything is ok with the dump in fact.
as an option, the forced specification of the encoding in .htaccess
in one of the projects on shared hosting can help me, the first three directives were enough to solve a similar problem.
AddDefaultCharset UTF-8
AddCharset UTF-8 .php
php_value default_charset "UTF-8"
php_value iconv.input_encoding "UTF-8"
php_value iconv.internal_encoding "UTF-8"
php_value iconv.output_encoding "UTF-8"
php_value mbstring.internal_encoding UTF- 8
php_value mbstring.http_output UTF-8
php_value mbstring.encoding_translation On
php_value mbstring.func_overload 6
Are you migrating through phpMyAdmin?
There, like, you can choose the encoding. Well, or when exporting to a file, add the encoding you need yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question