rawurlencode

Returns a string where all non-alphanumeric characters, except -_.~, are replaced by a percent sign (%) followed by two hexadecimal digits.
Produces results similar to the PHP function rawurlencode().