Skip to content

Instantly share code, notes, and snippets.

@blacksmoke26
Last active June 15, 2017 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacksmoke26/e6d01c0b8fe9c8ec13e9 to your computer and use it in GitHub Desktop.
Save blacksmoke26/e6d01c0b8fe9c8ec13e9 to your computer and use it in GitHub Desktop.
Multibyte URL-encode according to UTF-8
<?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