Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

ERB::Util.u

u(s)

Alias of .url_encode

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 .html_escape .h also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0