Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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