Daria
Daria

Reputation: 861

PHP and XML UTF-8 got characher codes instead of characters itself

I'm retreiving some data from Sybase ASE database to build some xml string. When I echo this string it looks okay, but pressing Ctrl+U (that brings you to view-source mode) I'm getting something like this: node_name="Негативотсутствует"

And after I need to write this string to a file, and I'm getting the same confuse... mb_detect_encoding says UTF-8. How can I fix this and make it displays as normal readable string?

UPD I got it. My XML string was created worng, without encoding definition. Adding encoding=\"utf-8\" solved problem.

Upvotes: 1

Views: 37

Answers (1)

igorshmigor
igorshmigor

Reputation: 802

Use html_entity_decode() or htmlspecialchars_decode() to convert this string back to normal.

http://php.net/manual/en/function.html-entity-decode.php

http://php.net/manual/en/function.htmlspecialchars-decode.php

Upvotes: 2

Related Questions