Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Non asci character and system call

by Anonymous Monk
on Nov 09, 2017 at 07:46 UTC ( #1203000=note: print w/replies, xml ) Need Help??


in reply to Re: Non asci character and system call
in thread Non asci character and system call

Thank you. My machine uses CP1251 (just tested), but telling the system to encode the string as you suggested turns out to fire "Couldn't launch '$commandline': $!/$?" the same.

  • Comment on Re^2: Non asci character and system call

Replies are listed 'Best First'.
Re^3: Non asci character and system call
by vr (Friar) on Nov 09, 2017 at 10:05 UTC

    Works for me. Is your $commandline as simple as shown? It may have characters outside of ANSI CP, or characters that need escaping (quoting). Try pasting its content directly to command prompt and see if it's working. Or maybe file is not in current directory.

    use strict;
    use warnings;
    use feature 'say';
    use utf8;
    use Encode 'encode';
    use Win32;
    
    say Win32::GetACP;      # 'ANSI Code Page'
    say Win32::GetOEMCP;    # 'OEM Code Page'
    
    my $commandline = qq{start "" "сервис.pdf"};
    system( encode 'CP'. Win32::GetACP, $commandline ) == 0
    or die encode 'CP'. Win32::GetOEMCP, qq{Couldn't launch '$commandline': $!/$?};
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1203000]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-04-20 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?