Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

library for doing html escaping...

0 views
Skip to first unread message

Sean T Allen

unread,
Apr 29, 2005, 3:41:43 PM4/29/05
to
ruby forge drives me crazy trying to find things...

need a library that provides simple functionality of take a string and
doing html escaping

" to "
& to &

etc.

suggestions....

sean.vcf

Phlip

unread,
Apr 29, 2005, 3:48:03 PM4/29/05
to
Sean T Allen wrote:

> ruby forge drives me crazy trying to find things...

Sometimes what you seek was obvious to everyone else, so they didn't
excessively document it. Sorry.

> need a library that provides simple functionality of take a string and
> doing html escaping
>
> " to "
> & to &

require 'cgi'
...

def test_escapeHTML()
scream = CGI::escapeHTML(">scream<")
assert_equal(scream, '&gt;scream&lt;')
end

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Ara.T....@noaa.gov

unread,
Apr 29, 2005, 3:56:09 PM4/29/05
to
On Sat, 30 Apr 2005, Sean T Allen wrote:

> --------------090403080404050404020301
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Content-Transfer-Encoding: 7bit

it's builtin to ruby:

harp:~ > irb -r cgi
irb(main):001:0> CGI::escapeHTML %Q( " )
=> " &quot; "
irb(main):002:0> CGI::escapeHTML %Q( & )
=> " &amp; "
irb(main):003:0> CGI::escapeHTML %Q( < )
=> " &lt; "
irb(main):004:0> CGI::escapeHTML %Q( > )
=> " &gt; "

cheers.
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| renunciation is not getting rid of the things of this world, but accepting
| that they pass away. --aitken roshi
===============================================================================

0 new messages