Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

ERB::Util.u

(::String) -> ::String
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 also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0