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#escapeHTML

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

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

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