3

Possible Duplicate:
How to decode Unicode escape sequences like “\u00ed” 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.)

Community
  • 1
  • 1
Spyros
  • 46,820
  • 25
  • 86
  • 129
  • Dominic, this worked thanx ! I did not notice the duplicate because of the pretty verbose title :) It's like another question :P You make it an answer if you like, i will vote for it. – Spyros Jun 15 '11 at 19:56

1 Answers1

-2

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

Shef
  • 44,808
  • 15
  • 79
  • 90