I'm confused. Unicode::MapUTF8, based on a 30-second read of its doc, looks designed to work on pre-5.8 perls. Why would you use it rather than Encode? What do you need to do that Encode isn't doing for you? | [reply] |
I have used Encode on a recent project to convert between WinLatin1 and UTF8 | [reply] |
Encode has been working fine for me too, between ISO-8859-1 and UTF-8.
Wonderful module :-)
| [reply] |
But - I just think I'm misunderstanding the documents, or the fundementals of DBI. I'm not quite sure how one would go about using Encode. Do I - encode('utf8', decode('ENCODING', $database{column})) ?
| [reply] |
Okay, so it's just my idiocy the - encode('utf8',decode('encoding',$data)) - works a treat!
THanks a load for all your help guys, it's much appreciated. | [reply] |
Yes sorry, I'm just scanning documents hopelessly looking for help. I'm not sure about Encode - when I pull my data from the database, has Perl already converted it into UTF-8 for internal use? Would this mean I need to do no work ? I would I just &decode('windows-1250', $database{column}) - meaning the values returned from the decode function would be in UTF-8 ?
| [reply] |
# I'm sure you have a very different (more sensible) way of
# mapping table values to their proper legacy encodings, but
# this is just to show how to handle the data:
my %column_enc_map = ( columnA => 'cp1250',
columnB => 'cp1251',
# or whatever... );
for my $field ( keys %column_enc_map )
{
# replace the hash values from the database with utf8 strings:
$database{$field} = decode( $column_enc_map{$field}, $database{$fi
+eld} );
}
# %database values are now in utf8; you can load them back to the data
+base via updates
Looking at your later reply in this thread, I'm pretty sure you don't need the extra "encode()" step on top of the "decode". All that does is turn off the utf8 flag on the string, which is kind of pointless, I think. | [reply] [d/l] |
Wow, brilliant - many thanks for that explanation graff!
| [reply] |
perluniintro - Perl Unicode introduction
| [reply] |