Forum: Ruby on Rails Utility to translate HTML character entities into text?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2006-05-19 01:27
Anyone know of a Ruby utility that will translate HTML character
entities into text?

Thanks,
Wes
Alex W. (Guest)
on 2006-05-19 03:19
Wes G. wrote:
> Anyone know of a Ruby utility that will translate HTML character
> entities into text?
>
> Thanks,
> Wes

http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/cla...

Unescape a string that has been HTML-escaped

  CGI::unescapeHTML("Usage: foo "bar" <baz>")
     # => "Usage: foo \"bar\" <baz>"
Jens K. (Guest)
on 2006-05-22 22:12
(Received via mailing list)
On Fri, May 19, 2006 at 01:19:37AM +0200, Alex W. wrote:
>
>   CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
>      # => "Usage: foo \"bar\" <baz>"

this seems to only decode  lt, gt and amp entities:

irb(main):003:0> CGI::unescapeHTML("&eacute;lan")
=> "&eacute;lan"

you should have a look at http://htmlentities.rubyforge.org/ if you want
to decode other entities, too.

Jens
This topic is locked and can not be replied to.