Skip to content

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

instance method

CGI::Escape#h

(::string str) -> ::String
h(string)

Alias of #escapeHTML

Escape special characters in HTML, namely '&\"<>

Example
CGI.escapeHTML('Usage: foo "bar" <baz>')
   # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"