Thread Unicode (ä, ö, ü in German) Problem with File::Fi (9 answers)
Opened by TeddyC at 2003-09-01 18:11

TeddyC
 2003-09-01 18:11
#82711 #82711
User since
2003-08-28
2 Artikel
BenutzerIn
[default_avatar]
I 'm new to Perl and not be able to locate my problem exactly. I've searched but can't find the right solution.I hope here is a right place to post.

Env: Win2000(en) +ActivePerl 5.8+ Komodo

The trouble begins with special characters in German.
I want to copy a whole directory to another location , a prototype got no problem with direct writing paths of source  and destination in program:
1) define $srcdir in perl-program
            $srcdir in perl-program
like this:
Code: (dl )
1
2
3
4
5
6
7
8
use File::Find;
# there are directory d:\perl\source\test\öa  and file d:\perl\source\test\öa\ü.txt under \test\

$srcdir="d:\\perl\\source\\test";  
$dstdir="d:\\test2";
finddepth(\&check_and_copy, $srcdir);

# sub check_and_copy  check the time of file/dir and only copy the updated file/dir to $dstdir

Then I wrote srcdir & dstdir in config.xml and use XML:Simple to read and got them in UTF8 format but  nothing is copied!
2) define $srcdir in xml
            $dstdir in xml

Komodo shows that  first $_ in "finddepth" is "d:\perl\source\test\öa"  (ö in Hex)
There are someting not correct: it should be "d:\perl\source\test\öa\ü.txt" by depth first search( just like in 1) )

Then I run the Program under Dos, it shows a warning: "Can't cd to <d:\perl\source\test/> öa ..." (here ö can't display correctly")

--Is there something wrong in  File::Find with utf8 or with utf8 under win2k?
--Or it depends on somethings else?


I made some tests but I can't understand the results well.

3) define $srcdir in perl-program
            $dstdir in xml

# the files is copied but the charater shows in Ascii format.

4) define $srcdir in perl-program and test
Code: (dl )
1
2
3
4
5
6
7
$srcdir="d:\\perl\\source\\test";  
if(Encode::is_utf8($srcdir) ){    
print " src is_utf8\n";
}else{
print " src is_NOT_utf8\n";
}
# I got "src is_NOT_utf8",  I heared Perl use UTF8 internal. but it seems that's not so simple.

5).define $srcdir with "ö" in perl-program and use utf8

Code: (dl )
1
2
3
use utf8;
$srcdir="d:\\perl\\source\\test\\öa";  
# I got "Malformed UTF-8 character (unexpected non-continuation byte 0x61, immediately after start byte 0xf6)"

--What 's the encoding of a Perl- program in Komodo?
--How can I got the  encoding's name  of a string?
--How can I got the right output  for "ä, ö ,ü" in  DOS? (I got correct character in Komodo with "binmode (STDOUT,"utf8");" )



Thanks  for your attention!\n\n

<!--EDIT|TeddyC|1062436104-->

View full thread Unicode (ä, ö, ü in German) Problem with File::Fi