ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I've got a UTF8 file (set in "UTF-8 without BOM" in Notepad++), and I'm trying to convert it automatically to ANSI, so I can read it and place in my latin1 mySQL table
Thus far I have:
Am I invoking `iconv` incorrecty, or maybe something else?
Been driving me nuts for hours trying to fix this :(
BTW: doing a conversion with a perl module isn't really idea, due to the fact this file is 30+mb in size, and an XML file (so its not very effecient to keep using utf8($string)->latin; for every value in that XML file)
TIA!
Andy
I've got a UTF8 file (set in "UTF-8 without BOM" in Notepad++), and I'm trying to convert it automatically to ANSI, so I can read it and place in my latin1 mySQL table
Thus far I have:
This "seems" to work... but for some reason when I open this new file in NotePad++, it doesn't seem to recognise the encoding type (it also comes up weird in the DB, i.e "Vols + transferts + hébergement en formule "tout ...")system("iconv --from-code UTF-8 --to-code iso-8859-15 -c /var/home/sit +e/siteforum.com/www/admin/Plugins/Forum/Advertiser/Import/tmp/allVaca +tions.xml > /var/home/site/siteforum.com/www/admin/Plugins/Forum/Adve +rtiser/Import/tmp/allVacations.xml.new"); print qq|Done converting... \n|; system("perl -p -i -e 's|UTF-8|ISO-8859-15|g' *.new"); system("rm /var/home/site/siteforum.com/www/admin/Plugins/Forum/Ad +vertiser/Import/tmp/allVacations.xml"); print qq|Removed allVacations.xml... \n|; system("mv /var/home/site/siteforum.com/www/admin/Plugins/Forum/Ad +vertiser/Import/tmp/allVacations.xml.new /var/home/site/siteforum.com +/www/admin/Plugins/Forum/Advertiser/Import/tmp/allVacations.xml"); print qq|Moved file ... \n|; system("rm -f /var/home/site/siteforum.com/www/admin/Plugins/Forum +/Advertiser/Import/tmp/allVacations.xml.new"); print qq|Removed .new file... \n|;
Am I invoking `iconv` incorrecty, or maybe something else?
Been driving me nuts for hours trying to fix this :(
BTW: doing a conversion with a perl module isn't really idea, due to the fact this file is 30+mb in size, and an XML file (so its not very effecient to keep using utf8($string)->latin; for every value in that XML file)
TIA!
Andy
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: utf file to ansi, but doesn't work?
by moritz (Cardinal) on Feb 28, 2011 at 11:06 UTC | |
by ultranerds (Hermit) on Feb 28, 2011 at 12:00 UTC | |
by moritz (Cardinal) on Feb 28, 2011 at 12:32 UTC | |
by ultranerds (Hermit) on Feb 28, 2011 at 13:27 UTC | |
by eff_i_g (Curate) on Feb 28, 2011 at 15:24 UTC | |
by ikegami (Patriarch) on Feb 28, 2011 at 16:49 UTC | |
by eff_i_g (Curate) on Feb 28, 2011 at 17:44 UTC | |
| |
by fullermd (Priest) on Mar 01, 2011 at 08:53 UTC | |
Re: utf file to ansi, but doesn't work?
by ikegami (Patriarch) on Feb 28, 2011 at 16:54 UTC |
Back to
Seekers of Perl Wisdom