Module: PHPRB::Util

Defined in:
lib/web/phprb.rb

Instance Method Summary collapse

Instance Method Details

#html_escape(s) ⇒ Object Also known as: h



454
455
456
# File 'lib/web/phprb.rb', line 454

def html_escape(s)
  s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end

#url_encode(s) ⇒ Object Also known as: u



459
460
461
# File 'lib/web/phprb.rb', line 459

def url_encode(s)
  s.to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
end