hoffj has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: converting utf-8 to ISO-8859-1
by bart (Canon) on Apr 22, 2005 at 02:17 UTC | |
by graff (Chancellor) on Apr 22, 2005 at 04:31 UTC | |
by bart (Canon) on Apr 22, 2005 at 07:19 UTC | |
|
Re: converting utf-8 to ISO-8859-1
by gaal (Parson) on Apr 21, 2005 at 20:17 UTC | |
by phaylon (Curate) on Apr 21, 2005 at 20:19 UTC |