Howdy Monks. I am having a fun Saturday afternoon trying to get Perl to play nice with MySQL to move Arabic text between two schemas. Here is the relevant code chunk (source db has already been connected, etc):
my $sqlstatement = 'select name_arabic from data'; my $sth = $dbh->prepare($sqlstatement); my @row; my @cases; $sth->execute || die "Could not execute MySQL statement: $sqlstatement +"; while (@row=$sth->fetchrow_array) { push(@cases, [ @row ]); } $sth->finish(); for my $i (0..$#cases) { my $sqlstatement = 'insert into newdb.names (arabicname) values (? +)'; my $sth = $dbh->prepare($sqlstatement); $sth->execute($cases[$i][0]) || die "putsql could not execute MySQ +L statement: $sqlstatement"; $sth->finish(); }
In both the existing source table and the newdb table, the column charset is set to cp1256 (which is windoze arabic). When I look at the data table in the source db with a viewer that will show that charset, it shows the arabic chars.

After running the above code, when I look at newdb.names with the same viewer, it shows question marks substituted for the arabic chars.

So it would seem that in the course of reading and/or writing the data I am hosing up the char encoding somehow. Anyone know how I can straighten it out?

Thanks...Steve


In reply to Trouble with Perl MySQL Arabic by cormanaz

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.