Is ther any built in function in PHP to decode
przysi%25C4%2599gam%2520s%25C5%2582u%25C5%25BCy%25C4%2587
into
przysięgam służyć
?
Is ther any built in function in PHP to decode
przysi%25C4%2599gam%2520s%25C5%2582u%25C5%25BCy%25C4%2587
into
przysięgam służyć
?
urldecode — Decodes URL-encoded string
But I think that won't work on multibyte strings. See the comments on the manual page for possible userland workarounds and also http://www.zend.com//code/codex.php?ozid=839&single=1
Have you tried this:
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');;
}
Taken from http://php.net/manual/en/function.urldecode.php
Edit: Your initial string is messed up. Did you urlencode it twice? Cause utf8_urldecode(utf8_urldecode($encoded string)) gives the correct result.
My guess is that you have issues with urldecode and multibyte characters. Urldecode can only decode 8 bit characters and your string contains multibyte characters.
Check the urldecode manual page comments for some solutions.
Ok, Gordon and Manos, you're both right (and both wrong ;)
It's just normal 'urldecode', but applied twice
$a = "przysi%25C4%2599gam%2520s%25C5%2582u%25C5%25BCy%25C4%2587";
$b = urldecode(urldecode($a));
var_dump($b);