I need to pull some info about an article out of a database and display it on a Web page, but ran into a problem with non-english text.

The text was taken from a utf-8 XML document and put into an Oracle database. I want to get it out of the database and then display it in an HTML page as iso-8859-1.

Addition (4/22): After reviewing the xml documents, I found that the xml document contains entities and not the special characters (as I had previously thought).

For example: 'Jos&\#233; El&\#237;as' 'José Elías' was parsed from the XML document and stored in the db as 'José Elía'. When I query and display the text it displays as 'José Elía'.

I want the text to display properly on the page, so I need to either convert it back to 'José Elía' or I could display it as 'Jos&\#233 El&\#237a'. What is the best way to accomplish this?

This is only a problem with the title and author, the rest of the page renders properly as iso-8859-1.

Here is what the script is currently doing:

... print qq( <span class='textTitles'>$article->{'title'}</span><br> Publication Date: $article->{'pub_date'}<br> Author: $article->{'author'}<br> Price: @{[ PrintablePrice($format_list[0]) ]}<br> ); ...

UPDATE (4/22):

Thanks for all of the responses.

FYI - I am using perl 5.8.

Using encode, decode and Bart's solution did not produce the proper results--the data was unchanged.

I have a major complication... see the addition above. I don't even know what the title of this question should be now. How can I get back to the correct entity or special character?


In reply to converting utf-8 (entities?) to ISO-8859-1 by hoffj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.