Weird character issue

H

Hoi-Polloi

Hi all

I'm using Perl 5.6, and I am seeing a very strange behavior with
creating files with utf8 chars in the name. Here's a little program:

use utf8;
use charnames ':full';

my $A = "\x{C1}"; # latin capital letter a with acute
my $AAA = "_" . "$A" . "$A" . "$A";
my $AAA1 = "$A" . "$A" . "$A";
system("echo 'AAA' > $AAA");
system("echo 'AAA1' > $AAA1");

If I run it, then do 'ls' I get the following:
# ls
_ÁÁÁ Ã?ÁÁ
# ls | od -a
qa-tterry-1# ls | od -a
0000000 _ ? 81 ? 81 ? 81 nl ? 83 ? 81 ? 81 ?
81
0000020 nl
0000021

In other words, the first character of the AAA1 file is not latin
capital a acute. I am surprised that putting "_" at the beginning of
the string makes a difference. What is going on here?

Thanks,
TT
 
P

Peter J. Holzer

I'm using Perl 5.6, and I am seeing a very strange behavior with
creating files with utf8 chars in the name. Here's a little program:

use utf8;
use charnames ':full';

my $A = "\x{C1}"; # latin capital letter a with acute
my $AAA = "_" . "$A" . "$A" . "$A";
my $AAA1 = "$A" . "$A" . "$A";
system("echo 'AAA' > $AAA");
system("echo 'AAA1' > $AAA1");

If I run it, then do 'ls' I get the following:
# ls
_ÃÃà Ã?ÃÃ
# ls | od -a
qa-tterry-1# ls | od -a
0000000 _ ? 81 ? 81 ? 81 nl ? 83 ? 81 ? 81 ?
81
0000020 nl
0000021

In other words, the first character of the AAA1 file is not latin
capital a acute. I am surprised that putting "_" at the beginning of
the string makes a difference. What is going on here?

Firstly, please upgrade to a current version of perl. Perl 5.6.0 was the
first version with some UTF-8 support, and it has many issues which have
since been fixed. People will probably ignore your UTF-8 problems if you
don't have at least perl 5.8.1.

Secondly, you are using system to invoke a shell command. The problem
could be a shell problem just as easily as it could be a perl problem.
If you want to demonstrate that it is a perl problem you should use
open to create the file. (and in any case you should explicitely encode
the filename).

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top