Reputation: 5281
I am trying to scrape a webpage in arabic and everything works fine except the fact that when i echo the text what i get is a garbled up text even though i have set the header to UTF-8
Here is my code
<?php
header ('Content-Type: text/html; charset=UTF-8');
require 'vendor/autoload.php';
use Goutte\Client;
$client = new Client();
$crawler = $client->request('GET', 'http://www.lebanonfiles.com');
$news_container = $crawler->filter('#mcs4_container .line');
$news_container->each(function($node) {
echo $node->text();
})
?>
What i get is this piece of garbled text
Upvotes: 1
Views: 6006
Reputation: 26450
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
header('Content-Type: text/html; charset=utf-8');
php.ini
file, using default_charset = "utf-8"
, although this is standard in PHP 5.6There might be different aspects of your code that needs to be set to a specific charset.
Upvotes: 1
Reputation: 898
You should try this... try to put this line at beginning of your php file: ini_set('default_charset', 'UTF-8');
this may solve your issue.
Have a nice day.
Upvotes: 1