Good day! I create an XML page. The data I take from MySQL using SELECT. The table has the utf8_general_ci encoding. I create XML using the usual echo . When I deduce the Russian text from the table:

<text> $row[text] </text> 

then get

   !                  ... 

even though the php file itself is in UTF without BOM and the XML text header is:

 <?xml version="1.0" encoding="utf-8"?> 

Please help. What to do with this encoding? And is it normal that this is a .php file. And the fact that in it the code of extraction from the table and other functions? And please note that this is only inside this xml. Prior to this is echo with the Russian text. It works fine.

ps English is displayed without problems.

Adding for Shrek: alt text

  • So all the same data from the database is not in UTF-8 - Artem
  • Added a screenshot in the first post. Maybe there are ways to check which encoding? Or convert? - Emil Sabitov
  • AddDefaultCharset UTF-8 already exists in .htaccess - Emil Sabitov

1 answer 1

Achieved the desired result by adding the following:

 mysql_query("set names 'utf8'"); mysql_query ("set character_set_client='utf8'"); mysql_query ("set character_set_results='utf8'"); mysql_query ("set collation_connection='utf8_general_ci'"); 

With what it can be connected?

And another question: When I create XML via echo, I don’t see the tags on the page. Only what is written in them. It is right?

  • one
    Naturally. Similarly, if we wrote echo '<p> Text </ p>'; you would only see the word Text , but without tags. - Deonis
  • But then the parser can easily recognize XML? - Emil Sabitov
  • one
    The word parser is already used as they want, so I don’t even know what meaning you put into this concept. In general, XML is essentially the same markup language as HTML. So why should it be difficult? - Deonis
  • I apologize for my inability to express myself correctly. Grateful that they understood correctly. I will read the exact definition of the parser. And for the answers - thanks! - Emil Sabitov
  • Why can't I accept my answer? how to be?) - Emil Sabitov