Answer the question
In order to leave comments, you need to log in
From xml(utf-8) to db(cp-1251)?
Hello.
There is data in the xml file in utf-8 encoding. Parsed xml in php and inserted into the database.
But when I had to insert it into the database with the cp-1251 encoding, the bugs started.
Through Notepad I changed the encoding, and chose to use 'ANSI' - all the same, only krakozyabry.
How to get rid of krakozyabr?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
You need to convert the data to the format of your database, because Cyrillic characters in ANSI, UTF-8 and CP-1251 are different.
$data = { parse xml}
foreach ($data as $key => $value) {
if (!mb_check_encoding($value, 'Windows-1251')) {
$data[$key] = mb_convert_encoding($value, 'UTF-8', 'Windows-1251');
}
}
{insert data to $db}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question