PHP: 8 character UTF encoding

I clear the list of RSS feeds using cURL and then I read and parse the RSS data using SimpleXML. Then the sorted data is inserted into the mySQL database.

However, as a notification at http://dansays.co.uk/research/MNA/rss.php I am having several problems with the incorrect display of characters.

Examples:

âGuitar Hero: Van Halenâ Trailer And Tracklist Available

NV 10/10/09 â€" Salt Lake City, UT 10/11/09 â€" Denver, CO 10/13/09 â€"

I tried using htmlentities and htmlspecialchars for the data before inserting them into the database, but it doesn't seem to help solve the problem.

How can I solve this problem that I have?

Thanks for any advice.

Update

I tried what Greg suggested, and the problem is still here ...

Here is the code I used for SET NAMES in PDO:

$dbh = new PDO($dbstring, $username, $password); 

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 

$dbh->query('SET NAMES "utf8"');

simplexml, , , - cURL...

cURL:

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');

$data = curl_exec($ch);

curl_close($ch);

$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);

RSS/HTML "UTF-8", . , , char . PHP6!

+3
4

, :

RSS-, cURL, - xml RSS-, ( , , , -)

RSS SimpleXML. - , SimpleXML - ?

mySQL. - hex (), () char_length () , .

http://hangout.altsounds.com/external.php?type=RSS2, http://validator.w3.org/feed/. iso-8859-1, , , - cp1252 - , 0x93 - http://www.fileformat.info/info/unicode/char/201C/charset_support.htm.

, , - Firefox, , , , , SimpleXML 0x93 utf8, 0xc293, .

2

- "ISO-8859-1" "Windows-1252" , Simple XML. 100%, , UTF8.

, , , , , , , utf8 . , , , , , , ( -), . , , , - , .

+2

UTF-8, .

, UTF-8 SELECT INSERTS - MySQL:

SET NAMES "utf8"
+3

CURLOPT_ENCODING: Accept-Encoding, . accept - "", "" "gzip".

+2

, XML, , :

<?xml version="1.0" encoding="ISO-8859-1" ?>

, libxml, SimpleXML, . XML, , HTML- META, .

XML- ( , HTML META) utf8_encode() ​​SimpleXMLElement.

+1

Source: https://habr.com/ru/post/1714876/


All Articles