Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

ERB::Util.url_encode

(::String) -> ::String
url_encode(s)

A utility method for encoding the String s as a URL.

Example
require "erb"
include ERB::Util

puts url_encode("Programming Ruby:  The Pragmatic Programmer's Guide")

Generates

Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
See also #url_encode .u #u also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0