Solved

Php cURL problem for showing html source

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 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

19 Experts available now in Live!

Get 1:1 Help Now