How to determine if a command line argument has already been decoded?

I would like to decode @ARGVif (and only if) the script was not running with the command line option -CA. For instance:

use strict;
use warnings;

use Encode qw(decode_utf8);
BEGIN {
    if ( ... ) {    # <--- What condition to put here?
        @ARGV = map { Encode::decode_utf8( $_ ) } @ARGV;
    }
}

I found the variable ${^UNICODE}in perlvarand perlrun, but it seems that it has not documented which bit matches the value A.

+4
source share
1 answer

perlrunsays that Apart of the flag -Cmatches 32(my selection).

5.8.1 -C , . , - ; .

[...]
A    32   the @ARGV elements are expected to be strings encoded
          in UTF-8

, ${^UNICODE} , -C. , , -CA , !( ${^UNICODE} & 0x20 ).

+4

Source: https://habr.com/ru/post/1672232/


All Articles