Solved

Php cURL problem for showing html source

Posted on 2013-01-30
3
331 Views
Last Modified: 2013-10-10
Hello,
I wanna retrieve html page content with curl and show it, i can print english pages like google, but for arabic content i have a problem and result is smth like following code:
¿X¿M¿u~¿¿G¿¿]¿¿¿¿¿¿4o¿UU¿¿¿u{]¿¿i¿|¿¿y¿¿G ¿n¿y¿~¿¿¿¿¿¿]{¿¿¿~¿$¿¿q3¿¿U¿¿¿¿2¿O¿-¿¿¿X¿¿¿¿¿T[;¿t¿¿a¿¿:o¿¿{z?¿¿b¿¿G¿¿5¿¿y¿n¿¿c¿W¿u¿e¿x|¿^"¿$¿_O¿¿5¿¿¿¿^¿¿lAx¿¿¿¿E¿¿+¿¿jh¿¿¿d¿v\¿Ys¿Z¿¿M¿V¿¿}¿Wwv¿Y¿z¿{¿¿¿¿¿3¿¿#¿&¿N¿>¿¿¿Q,WkC¿y1¿¿¿¿¿¿¿?¿¿¿o¿¿¿¿¿¿¿¿2+¿¿P¿¿fH¿¿W_¿¿¿¿¿¿¿¿~¿¿¿¿^H¿¿¿¿g¿¿}¿¿¿¿¿¿}¿P¿^¿¿|z¿¿¿¿s¿{_¿¿WW/¿¿¿¿¿>¿8;9¿¿¿¿¿8¿u¿o¿¿y¿¿xv¿¿¿¿¿¿=¿¿w~¿¿x¿¿¿¿u¿¿g;¿¿w¿¿¿¿¿¿¿t¿¿¿¿¿O^¿>{?¿¿¿¿wZ¿}¿¿'¿¿}¿'¿}u¿¿|¿¿W¿¿¿¿¿¿'¿¿O¿ ¿¿¿¿¿¿¿¿>¿^Q¿¿¿¿gO¿¿¿¿¿5¿>¿¿¿~¿¿¿¿¿¿¿¿¿¿N/¿¿'O¿¿S¿¿w~¿}¿¿¿¿¿¿?¿¿¿L¿¿8¿¿¿¿¿n¿¿*_~¿~9¿_]¿>¿j¿=¿¿}¿V¿¿¿¿O

Open in new window


my sample code is:
/* gets the data from a URL */
function get_data($url) {
	$ch = curl_init();
	$timeout = 5;
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$data = curl_exec($ch);
	curl_close($ch);
	return $data;
}

$returned_content = get_data('http://www.google.com');

echo $returned_content;

Open in new window

0
Comment
Question by:re-searcher
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38837982
That means you have a 'character set mismatch' where the character set of the web site you're getting that from is not the same as your own web site or possibly the PHP/curl code.

One example: http://php.net/manual/en/function.curl-setopt.php

Check that web site and your own to see what character set encodings they are using.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question