davis has asked for the wisdom of the Perl Monks concerning the following question:
NB: I've been living inside my ASCII shell for as long as possible, but I'm just starting to look at unicode data. My understanding of how to manipulate it is limited.
I've been using a perl script to turn a bunch of Microsoft Excel files into XML files, and from there, import them into a MySQL DB. Recently I've spotted some non-ASCII values in the Excel files, such as "ß". I decided that, since Perl's got Unicode support, I'll turn the contents of the spreadsheets into utf8, then import them into the database, and display the results in an HTML page via another Perl script.
I'm having trouble with this, and I'm not sure where the problem is. What I do:
my $xs = new XML::Simple(ForceArray => 1, KeyAttr => 1, KeepRoot => 1, + NoAttr => 1); print '<?xml version="1.0" encoding="UTF-8"?>', "\n"; print $xs->XMLout(\%foo, RootName => "foo");
Assumption Number 1: I'm assuming, at this point, my XML files will contain valid Unicode data (there's a couple of funny characters in place of the German "double-s" character). I do not know how to prove this, but the files are slurped in again with XML::Simple ok.
The data is then read in by another Perl script (using XML::Simple), and put into the database (MySQL 4.0.20, which may have dubious utf8 support -- I'm not sure). The column in question was declared of SQL type "varchar(255) character set utf8", and the field in the database looks the same (to me) as the value in the XML file.
Assumption Number 2: The utf8 data has made it into the database successfully.
I then want to display the same data (using HTML::Template) in an HTML file. The trouble is, even with a '<?xml version="1.0" encoding="UTF-8"?>' at the front, the HTML as displayed in my browser (and in the HTML source) isn't the correct character. It looks like it's the same "funny characters" as in the XML file and the database.
Assumption Number 3: I need to do something here to convert the value stored in the database to the HTML unicode entity.
Are my assumptions correct? If so, how do I get well-formed, valid, (and correct!) HTML in my browser?
Cheers
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mildly OT: Excel Order Forms -> XML -> MySQL -> HTML with unicode
by jZed (Prior) on Oct 06, 2004 at 15:21 UTC | |
by davis (Vicar) on Oct 06, 2004 at 15:33 UTC | |
|
Re: Mildly OT: Excel Order Forms -> XML -> MySQL -> HTML with unicode
by iburrell (Chaplain) on Oct 06, 2004 at 16:39 UTC | |
by davis (Vicar) on Oct 22, 2004 at 10:01 UTC | |
by Anonymous Monk on Oct 07, 2004 at 14:32 UTC | |
|
Re: Mildly OT: Excel Order Forms -> XML -> MySQL -> HTML with unicode
by Anonymous Monk on Oct 06, 2004 at 15:12 UTC |