Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Files with arabic names

by 1nickt (Canon)
on Jul 13, 2017 at 18:44 UTC ( [id://1195066]=note: print w/replies, xml ) Need Help??


in reply to Files with arabic names

Same way as any other file, with unlink. Your computer doesn't care what language the filename is in.

$ perl -Mstrict -MPath::Tiny -wE '
my $filename = "شاب مراد كالعادة يصرع";
path( $filename )->spew("Hello, world");
say qx{cat "$filename"};
unlink $filename;
say qx{ls "$filename"};
'
Hello, world
ls: شاب مراد كالعادة يصرع: No such file or directory

Perhaps you meant something else? Maybe you need to learn about character encoding? See for example perlunitut, or this node.


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Files with arabic names
by Corion (Patriarch) on Jul 13, 2017 at 18:52 UTC

    This is only true if the character encoding used is the same between Perl and the other process(es) showing the files.

    On Unixish systems, filenames are opaque blobs of octets and all interpretation of them as UTF-8 octets is solely by convention.

    On Windows systems, filenames are encoded as wide characters (UTF-16) and you have to use the Wide APIs to access/delete them. If your filenames are encoded as UTF-8, you have to change their encoding to UTF-16 when talking to the Windows API.

    Win32::Unicode helps there.

      Well, the OP was rather vague about where the filenames were, and his real issue is character encoding, not deleting files, don't you think? That's what I was attempting to point out.


      The way forward always starts with a minimal test.
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1195066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-03-28 22:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found