http://www.perlmonks.org?node_id=912446


in reply to Re: how to make a filename in unicode characters
in thread how to make a filename in unicode characters

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

Replies are listed 'Best First'.
Re^3: how to make a filename in unicode characters
by Corion (Patriarch) on Jul 02, 2011 at 07:49 UTC

    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.