Solved

Php cURL problem for showing html source

Posted on 2013-01-30
3
330 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now