note 100313 added to function.rawurlencode

From: Date: Thu, 07 Oct 2010 13:25:13 +0000
Subject: note 100313 added to function.rawurlencode
Groups: php.notes 
Request: Send a blank email to php-notes+get-173053@lists.php.net to get a copy of this message
I've written a simple function to convert an UTF-8 string to URL encoded string. All the given characters are converted! The function: <?php function mb_rawurlencode($url){ $encoded=''; $length=mb_strlen($url); for($i=0;$i<$length;$i++){ $encoded.='%'.wordwrap(bin2hex(mb_substr($url,$i,1)),2,'%',true); } return $encoded; } ?> Example: <?php echo 'http://example.com/', mb_rawurlencode('你好'); ?> The above example will output: http://example.com/%e4%bd%a0%e5%a5%bd ---- Server IP: 69.147.83.197 Probable Submitter: 146.110.156.195 ---- Manual Page -- http://www.php.net/manual/en/function.rawurlencode.php Edit -- https://master.php.net/note/edit/100313 Del: integrated -- https://master.php.net/note/delete/100313/integrated Del: useless -- https://master.php.net/note/delete/100313/useless Del: bad code -- https://master.php.net/note/delete/100313/bad+code Del: spam -- https://master.php.net/note/delete/100313/spam Del: non-english -- https://master.php.net/note/delete/100313/non-english Del: in docs -- https://master.php.net/note/delete/100313/in+docs Del: other reasons-- https://master.php.net/note/delete/100313 Reject -- https://master.php.net/note/reject/100313 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173053) next »