Hi,

I have lots of text files and am inserting them into a database. The textfiles' encoding is different from each other. Some of them are UTF8, some iso-8859-9 and others cp1254. I am loading text file into a variable (this is the only way currently), and updating a row in the database. If it is UTF8, it should be inserted without changing the encoding. If it is cp1254 or iso-8859-9 , then I need to decode the data first. However, I have no idea what the encoding is. Is there any way to determine the encoding? I will update 150.000 rows, so I would like to reduce the potential errors as much as I can.

I tried Encode::Guess,

my $decoder = guess_encoding($data, qw/iso-8859-9 cp1254/);

It says: "iso-8859-9 or cp1254", but the correct encoding is cp1254. So, it is also not useful.

What do you suggest? Are there any workarounds or solution for this?

Thanks in advance,


In reply to Encoding Problem by anlamarama

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.