For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > April 2005 > rename not working on files with accents in names









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author rename not working on files with accents in names
Tom Bates

2005-04-24, 3:56 am

ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...

The statement:
rename $src, $dst;
returns an error when $src is:
Tecatitlán.txt
If I remove the accented character, the rename operation succeeds.

I tried using File::Copy's move operation as well as setting
${^WIDE_SYSTEM_CALLS} to 1. Neither works.

Any suggestions?
TIA
tbone
Chris Mattern

2005-04-24, 3:56 am

Tom Bates wrote:

> ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...
>
> The statement:
> rename $src, $dst;
> returns an error when $src is:
> Tecatitlán.txt
> If I remove the accented character, the rename operation succeeds.
>
> I tried using File::Copy's move operation as well as setting
> ${^WIDE_SYSTEM_CALLS} to 1. Neither works.
>
> Any suggestions?


Print out $! to have it tell you what the error is. The obvious
one that occurs to me is that Perl doesn't think you have a file
named Tecatitlán.txt because Perl and the OS aren't using the
same character encoding scheme.

> TIA
> tbone


--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
Tad McClellan

2005-04-24, 8:56 am

Tom Bates <noneedto@email.me> wrote:

> The statement:
> rename $src, $dst;
> returns an error when $src is:
> Tecatitlán.txt



> Any suggestions?



I suggest sharing the text of the error message!


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Tom Bates

2005-04-24, 3:56 pm

Thanks for reminding me about being able to see the actual error info
(I referred to the Perl help pages for the available error variables).
After the rename fails:

$! == "No such file or directory"
$^E == "The system cannot find the file specified"
$? == 0

I have many files with other accented characters that cause the same
problem, BTW. I'm just using this one to narrow down the problem.

Thanks for the help...
tbone

On Sat, 23 Apr 2005 23:04:54 -0400, Tom Bates <noneedto@email.me>
wrote:

>ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...
>
>The statement:
> rename $src, $dst;
>returns an error when $src is:
> Tecatitlán.txt
>If I remove the accented character, the rename operation succeeds.
>
>I tried using File::Copy's move operation as well as setting
>${^WIDE_SYSTEM_CALLS} to 1. Neither works.
>
>Any suggestions?
>TIA
>tbone


Chris Mattern

2005-04-25, 3:58 am

Tom Bates wrote:

> Thanks for reminding me about being able to see the actual error info
> (I referred to the Perl help pages for the available error variables).
> After the rename fails:
>
> $! == "No such file or directory"
> $^E == "The system cannot find the file specified"
> $? == 0
>
> I have many files with other accented characters that cause the same
> problem, BTW. I'm just using this one to narrow down the problem.


Please don't top-post. Put your reply after the text you are replying
to. That said, I firmly believe that your problem is that your Perl
program and Windows aren't using the same character set--that is,
"á" in your Perl program and "á" on your command line aren't in fact
the same character. As I very rarely need to fool with non-ASCII
character sets, I'll leave your solutions to somebody who understands
them better.
[color=darkred]
>
> Thanks for the help...
> tbone
>
> On Sat, 23 Apr 2005 23:04:54 -0400, Tom Bates <noneedto@email.me>
> wrote:
>

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
Chris Mattern

2005-04-25, 3:58 pm

Chris Mattern wrote:

> Tom Bates wrote:
>
>
> Please don't top-post. Put your reply after the text you are replying
> to. That said, I firmly believe that your problem is that your Perl
> program and Windows aren't using the same character set--that is,
> "á" in your Perl program and "á" on your command line aren't in fact
> the same character. As I very rarely need to fool with non-ASCII
> character sets, I'll leave your solutions to somebody who understands
> them better.


It occurs to me that there is a simple test for this. Have your
Perl program create "Tecatitlán.txt". Then look at the file
in Windows. If it has a weird character instead of "á", then
that's your problem.

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com