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:

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|;
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 ...")

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

In reply to utf file to ansi, but doesn't work? by ultranerds

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.