public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5
def url_escape(string)
string.gsub(/([^ ;\/?:@=#&a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase
end.tr(' ', '+')
end

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.