我想替换 unicode \ u00a0 与 php 中的实际数据。
示例:NSDictionary *environment = [[NSProcessInfo processInfo] environment];
答案 0 :(得分:1)
\u00a0是NO-BREAK SPACE
要解码escape sequence
中的任何 PHP
,您可以使用此功能:
function unicodeString($str, $encoding=null) {
if (is_null($encoding)) $encoding = ini_get('mbstring.internal_encoding');
return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/u', create_function('$match', 'return mb_convert_encoding(pack("H*", $match[1]), '.var_export($encoding, true).', "UTF-16BE");'), $str);
}
echo unicodeString($str);
//<b>Sort By - </b><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/atoz/1.html">A to Z | </a><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/recent/1.html">Recently Added | </a><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/downloads/1.html">Most Downloaded</a>
样本:
如果您只需要替换单 escape sequence
,请使用:
$str = str_replace("\u00a0", " ", $str);
echo $str;
<b>Sort By - </b><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/atoz/1.html">A to Z | </a><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/recent/1.html">Recently Added | </a><a href="http://pagalworld.com/files/9704/Dil Dhadakne Do (2015) Mp3 Songs/downloads/1.html">Most Downloaded</a>