Hi,

After a whole afternoon trying to find out the problem I seek the wisdom of PerlMonks.

I've got a unicode file where, after processing, some lines will go into a Mysql (4.0.14) DB.

Using perl 5.8.0 I specified that the file is in utf8 by:

$txt_opener = new IO::File;<br> open( $txt_opener,'<:utf8', "$filetxt");
A little bit of processing later the script prints on console the data I want to insert into the DB and all foreign characters seem to be fine.

Once this goes into the DB using a standard SQL command and perl DBI driver the query executes fine.

However, using the console and/or phpmyadmin I interrogate the database and foreign characters ie. ñ, í are corrupted.

when the table is created the character set is specified "CHARACTER SET utf8".

Finally, if in this very same script I set a variable to a fix string with foreign characters ie. $var='ñíó' and execute using the same procedure the whole thing works fine.

So, the question is why if the variable gets assigned to a fixed string the thing works but if it comes from a dynamic assignment it fails to insert the data correctly.

I guess the problem is more related to perl than to mysql but sorry to ask in the wrong forum if this is not the case

Many thanks for your help!

Emilio.

Edit, BazB: added code tags.


In reply to Perl Mysql and UTF8 by emilioayllon

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.