use utf8;#no change if I use this or not
From the documentation for the utf8 pragma
(original emphasis retained):
Do not use this pragma for anything else than telling Perl that your script is written in UTF-8.
So, if you script includes the UTF-8 string "сервис.pdf", you should use it;
if it contains "xyz.pdf" (or whatever), you don't need it.
The thing to check here would be whether you've actually included "сервис.pdf" as a UTF-8 string.
If you've used some other encoding, that may be the cause of whatever issues you're encountering.
You haven't shown the assignment to $DocumentPath in your code;
nor have you actually said what problems you're experiencing:
"How do I post a question effectively?" provides guidelines on what information to include with your question such that we can better help you
(as an example, whatever value $! holds may be useful).
I'm wondering if whatever encoding your MSWin setup uses is behind the problem:
you're passing cyrillic from Perl; MSWin sees that as something completely different.
I don't have that available to test — I have:
$ perl -v | head -2 | tail -1
This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-th
+read-multi-2level
However, I can confirm that what you're attempting, has no basic flaws with respect to cyrillic.
Here's a little test one-liner (which I've split over several lines for ease of viewing):
$ perl -E '
use utf8;
my $f = "сервис.pdf";
my @c = (ls => $f);
if (-e $f) {
system @c
}
else {
say 0
}
'
Here's some test runs, with that one-liner reduced to just "perl -E '...'".
$ perl -E '...'
0
$ > сервис.pdf.
$ perl -E '...'
сервис.pdf
$ rm сервис.pdf
$ perl -E '...'
0
[In case you're unfamiliar with those commands,
">" is just creating an empty file with the name given
and "rm" removes (deletes) it.]
Posting non-ASCII code and data can be an issue.
I try to keep it to a minimum.
When it is needed, I use <pre>...</pre> instead of <code>...</code> for blocks;
and <tt>...</tt> instead of <c>...</c> within paragraphs.
You also need to replace special characters with entities
(e.g. s/&/&/, s/>/>/, etc.),
which is another reason to keep it minimal:
there's a list of those entities right after the textarea where you compose your node.
One final point, system takes a list of arguments.
Of course, that list could consist of a single string;
however, there's no need to programmatically concatenate the arguments into a single string.
See @c in my code above.
Update:
Oops!
Changed "replace entities with special characters"
to "replace special characters with entities".
|