PHP encoding and its corresponding JS-side decoding function
JS decoding function needs to run in the b.html generated by a.php, the encryption requirements are not high, but do not base64
Self-improvement, due to different PHP and JS code, resulting in the inability to restore
Http://topic.csdn.net/u/20121026/21/aa481d57-5268-4377-844a-11e0abf9fdd0.html?seed=358554303&r=80007043#r_ 80007043
------Solution--------------------
I don't know if it fits your needs.
echo compile (' AB in CD ');
function Compile ($code) {
$code = array_values (Unpack (' n '), Iconv (strlen (' Han ') ==2? ' GBK ': ' Utf-8 ', ' ucs-2 ', $code));
$c [] = $code [0] + count ($code);
for ($i =1; $i
$c [] = $code [$i] + $code [$i-1];
}
$r = ";
foreach ($c as $v) {
if ($v <) $r. = UrlEncode (Chr ($v));
else $r. = '%u '. Strtoupper (Dechex ($v));
}
return $r;
}
Results in GBK environment
F%c3%u4e8f%u4e90%c7 F%c3%u4e8f%u4e90%c7