in reply to how to make a filename in unicode characters

There are "almost no" problems. What have you tried and where did you encounter problems?

There is a problem with non-ascii filenames - Perl treats all filenames as opaque strings when it passes them to open. Depending on your combination of filesystem and operating system, you might get lucky and find that they also treat the filenames as opaque strings. Then you can just create files with any name you like and will find little problems out of the ordinary, when reading filenames from readdir or glob or text files.

For example on Windows+NTFS, the situation is different. Windows with NTFS encodes non-ascii filenames as UTF-16LE, but Perl does not use the proper APIs (yet) to access such files by their given name. This means that you will encounter interesting problems there where readdir returns filenames that do not match up with the names you find in text files or with a hardcoded filename you give in the source code.

Also see (found via site:perlmonks.org filename encoding)

  • Comment on Re: how to make a filename in unicode characters

Replies are listed 'Best First'.
Re^2: how to make a filename in unicode characters
by srikrishnan (Beadle) on Jul 02, 2011 at 07:41 UTC

    I have tried initially as per below code

    my $title = "​கோப்பு& +#8203;பெயர்"; open XXX, ">:encoding(UTF-8)", "c:/$title\.xml"; close (XXX);

    Then I tried something like below

    $title = encode("UTF-16LE", "​கோப&#3021 +;பு​பெயர்"); open XXX, ">:encoding(UTF-8)", "c:/$title\.xml"; close (XXX);

    In the above codes I am not used hexadecimal entities, straightaway characters, here it converts those characters to hexadecimal entitites

      Ah - so you need to tell Perl what encoding your source code is in - if you are certain that your source code is UTF-8, the utf8 pragma might help there. You should really check the return value of open by using either autodie or doing the following:

      open ... or die "Couldn't open '$filename': $!";

      Also, you're using the backslash ("\") as filename separator - I guess that you are on Windows then. See the reply by Anonymous Monk about using Win32::Unicode then.