5

I've read this question and I generally try to follow the ideas from Toms answer, but I have a problem with one thing.

How can I write my program so that it will treat command line arguments as UTF8 encoded?

It looks that I have two options:

  • use -CA option to perl
  • use PERL5OPTS env variable.

The problem is that I write my perl programs with shebang:

#!/usr/bin/env perl

as perl is in different locations on various systems I'm using.

This means - I can't use -CA option (or I don't know how, as #!/usr/bin/env perl -CA doesn't work.

I would also prefer to avoid having to specify special env vars before calling the script.

Is my only hope "manual" decoding of @ARGV, like:

use Encode;
@ARGV = map { decode( 'utf8', $_ ) } @ARGV;

or is there some better/nicer way?

Community
  • 1
  • 1
chu4Meek4e
  • 323
  • 2
  • 4

0 Answers0