开发者

How to unescape Javascript in PHP [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to decode Unicode escape sequences like “\u00ed&rdquo开发者_JAVA技巧; to proper UTF-8 encoded characters?

I have some javascript text that contains values like '\u003c' (less than sign <).

Is there a php functions that allows me to unescape javascript ?

(I did not expect urldecode to work, though i tried it. It does not indeed.)


yep, would just suggest it, urldecode();

Try:

<?php
  function utf8_urldecode($str) {
    $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
    return html_entity_decode($str,null,'UTF-8');;
  }
?>

Reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜