I've a string like this :
%d8%b7%d8%b1%d8%a7%d8%ad%db%8c-%d8%a7%d9%be%d9%84%db%8c%da%a9%db%8c%d8%b4%d9%86-%d9%81%d8%b1%d9%88%d8%b4%da%af%d8%a7%d9%87%db%8c
the meta tag of page is set to utf-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
i want to convert this unicode to pure readable utf-8 string
I've tested lots of code ,thie is my last code :
function convertFarsi($str) {
return html_entity_decode(preg_replace('/\\\\u([a-f0-9]{4})/i', '&#x$1;', $str),ENT_QUOTES, 'UTF-8');
}
and it doesn't work. How can I convert these unicode to utf8 string ?
You can use url_decode to get the following result:
<?php
$string = '%d8%b7%d8%b1%d8%a7%d8%ad%db%8c-%d8%a7%d9%be%d9%84%db%8c%da%a9%db%8c%d8%b4%d9%86-%d9%81%d8%b1%d9%88%d8%b4%da%af%d8%a7%d9%87%db%8c';
$outpout = urldecode($string);
echo $outpout; // طراحی-اپلیکیشن-فروشگاهی