PHP How to convert strings from DomCrawler to UTF-8

Viewed 745

I have some data I collect with DomCrawler and store in an array, but it looks like he fails when it comes to special characters like è,à,ï,etc.

As an example I get è instead of è when I echo the result.

When I store my results in a .json file I get this: \u00c3\u00a8 My goal is to save the special character in the .json file.

I've tried encoding it but doesn't seem to have the result I want.

$html = file_get_contents($url);
$crawler = new Crawler($html);

$h1 = $crawler->filter('h1');
$title = $h1->text();
$title = mb_convert_encoding($title, "HTML-ENTITIES", "UTF-8");

Is there anyway I can have my special characters shown?

Thanks a lot!

1 Answers
Related