Last active
June 15, 2017 13:17
-
-
Save blacksmoke26/e6d01c0b8fe9c8ec13e9 to your computer and use it in GitHub Desktop.
Multibyte URL-encode according to UTF-8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rawUrlEncode ( $str ) | |
{ | |
$encoded = ''; | |
$length = mb_strlen ($str); | |
for ( $i = 0; $i < $length; $i++ ) | |
{ | |
$encoded .= '%'.wordwrap ( bin2hex( mb_substr($str,$i,1) ), 2, '%', true ); | |
} | |
return $encoded; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment