note 63873 added to function.rawurldecode

From: Date: Sun, 02 Apr 2006 21:18:41 +0000
Subject: note 63873 added to function.rawurldecode
Groups: php.notes 
Request: Send a blank email to php-notes+get-107190@lists.php.net to get a copy of this message
This function also decodes utf8 strings so it behaves more like the javascript unscape() function. <?php function utf8RawUrlDecode ($source) { $decodedStr = ""; $pos = 0; $len = strlen ($source); while ($pos < $len) { $charAt = substr ($source, $pos, 1); if ($charAt == '%') { $pos++; $charAt = substr ($source, $pos, 1); if ($charAt == 'u') { // we got a unicode character $pos++; $unicodeHexVal = substr ($source, $pos, 4); $unicode = hexdec ($unicodeHexVal); $entity = "&#". $unicode . ';'; $decodedStr .= utf8_encode ($entity); $pos += 4; } else { // we have an escaped ascii character $hexVal = substr ($source, $pos, 2); $decodedStr .= chr (hexdec ($hexVal)); $pos += 2; } } else { $decodedStr .= $charAt; $pos++; } } return $decodedStr; } ?> ---- Server IP: 130.206.1.5 Probable Submitter: 81.37.61.129 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.rawurldecode.php Edit -- http://master.php.net/note/edit/63873 Del: integrated -- http://master.php.net/note/delete/63873/integrated Del: useless -- http://master.php.net/note/delete/63873/useless Del: bad code -- http://master.php.net/note/delete/63873/bad+code Del: spam -- http://master.php.net/note/delete/63873/spam Del: non-english -- http://master.php.net/note/delete/63873/non-english Del: in docs -- http://master.php.net/note/delete/63873/in+docs Del: other reasons-- http://master.php.net/note/delete/63873 Reject -- http://master.php.net/note/reject/63873 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107190) next »