Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Php cURL problem for showing html source

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
re-searcher
Asked:
re-searcher
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now