Skip to content
Create a gist now

Instantly share code, notes, and snippets.

def url_escape(string)
string.gsub(/([^ ;\/?:@=#&a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase' ', '+')

Ideal to encode URL with utf8 characters while keeping URL Specific Characters as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.