How to convert the HTML entities into UTF-8 character set, in ruby 1.8.7

Hi,

Is there away to convert the HTML entities into UTF-8 character set, in
ruby 1.8.7?
(For example, if we consider “”, convert the entity number “ö” into
“\303\266”. Or at least converting the html entity to the character “” )

Thank you

On Tuesday, 11 September 2012 04:02:22 UTC-4, Nila wrote:

Hi,

Is there away to convert the HTML entities into UTF-8 character set, in
ruby 1.8.7?
(For example, if we consider “”, convert the entity number “ö” into
“\303\266”. Or at least converting the html entity to the character “” )

Thank you

CGI.unescapeHTML may do what you’re looking for.

–Matt J.

On Sep 11, 2012, at 4:02 AM, Nila wrote:

Hi,

Is there away to convert the HTML entities into UTF-8 character set, in ruby
1.8.7?
(For example, if we consider “”, convert the entity number “ö” into
“\303\266”. Or at least converting the html entity to the character “” )

Here’s what I do:

coder = HTMLEntities.new
foo = coder.decode(foo)

I tried CGI.unescapeHTML and hit some problems, but that might have been
my source talking, since there were also custom entities declared in
XML.

Walter

Thanks alot for the responses. Could do it using HTMLEntities.