[Israel.pm] Perl-TK frame - showing Gibberish instead of Hebrew / Arabic characters from UTF-8 Input file.

Shmuel Fomberg semuelf at 012.net.il
Sun Jun 1 09:34:53 PDT 2008


Hi Oren.

To extend what Omer wrote, the string looks like hebrew in utf8, that 
was re-encoded to utf8.
You will probably fix that by telling Perl that your string is already 
utf8. do this by either opening the file with a utf8 flag:
open(my $fh, "< :utf8", $filename)
or by "converting" specific strings to utf8 by:
use Encode qw{decode_utf8};
my $line = <$fh>;
my $h_line = decode_utf8($line);

Good luck.
Shmuel.

Omer Zak:
> The gibberish looks as if the string from the text file was not decoded
> (converted into an Unicode string).
> I am not fluent in the Perl way of dealing with Unicode strings, so I
> apologize for being unable to offer more specific advice.
> 
> On Sun, 2008-06-01 at 12:43 +0300, Oren Maurer wrote:
>> Hi all
>> I'm trying my first steps with Perl/Tk.
>>
>> I want to read input text file and show the file contents on a frame.
>>
>> The input text file has Hebrew and / or Arabic characters.
>> It is saved as UTF-8.
>>
>> The Latin characters are displayed Ok. But the Hebrew / Arabic
>> characters are shown as Gibberish (I mean - those small 'x' and '[]'
>> instead of real Hebrew).
>>
>> For example:
>> 003134388 24633 H $$aכל ספוריו ×(c)ל ×(c)מואל יוסף ×¢×'× ×•×Ÿ
>>
>> Instead of:
>> 003134388 24633 H $$aכל ספוריו של שמואל יוסף עגנון
>>
>>
>> What can I do??
> 




More information about the Perl mailing list