[Israel.pm] Can't use Hebrew with perl on mysql 4.1

Rami Addady rami at active.co.il
Thu Sep 29 00:36:06 PDT 2005

OK now Perl can read and write Hebrew from mysql 4.1.

When the table define as utf, and the data was writing using perl and 
mysql 4.1.

The point is I need to import big sqldump of some DBs (from mysql 3.32) 
to mysql 4.1.10.
It contain non Unicode Hebrew values.

Perl is not reading the data properly and I don't want to change the 
perl application.

I try to convert the sql tables charset after the import using some 
mysql command like:
ALTER TABLE `hebtext` CHANGE `hebfield` `hebfield` VARCHAR( 255 ) 
CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ...

I try to convert the mysql 3.23 sqldump file before the import using:
iconv -f iso-8859-8 -t utf8 <input.txt >output.txt

But still Perl read and display the old data as ???? .

No problem with new data.


Mikhael Goikhman wrote:

>On 27 Sep 2005 18:58:59 +0300, Issac Goldstand wrote:
>>I was going to point out that Perl 5.8 keeps it strings in Unicode
>>(utf8, I believe).  To use this with MySQL, simply use utf8_general.  To
>>convert from ISO-8859-8 to utf8, try doing something like :
>>use Encode
>>open IN "iso-8859-8"
>>open OUT ">utf8"
>>while (<IN>) {print OUT $_};
>This syntax is not quite correct. Here is a working syntax (taken from
>Encode manual page):
>	open my $in,  "<:encoding(iso-8859-8)", $infile  or die;
>	open my $out, ">:encoding(utf8)",       $outfile or die;
>	while (<$in>) { print $out $_; }
>The magic is done by PerlIO itself, so no need in Encode module here.
>There is another way, using Encode function from_to:
>	open my $in,  "<", $infile  or die;
>	open my $out, ">", $outfile or die;
>	while (<$in>) {
>		from_to($_, "iso-8859-8", "utf8", 1);
>		print $out $_;
>	}
>But IMHO it is easier to convert files from unix:
>	iconv -f iso-8859-8 -t utf8 <input.txt >output.txt

More information about the Perl mailing list