utf8-all
utf8-all copied to clipboard
Does not work with -s switch
Linux Mint 20
Package: libutf8-all-perl
Version: 0.024-1
perl -Mutf8::all -sle 'print $v' -- -v=привет
пÑивеÑ
This does not work either:
perl -CASD -Mutf8 -Mv5.30 -sle 'print $v' -- -v=привет
This works:
perl -MEncode -sle 'print decode("utf-8", $v)' -- -v=привет
привет
By the way:
ruby -se 'puts $v' -- -v=привет
привет
and
awk -v v=привет 'BEGIN {print v}'
привет
Interesting, this is the first time I've seen -s in working. I'm not sure I will be able to fix this though; as far as I know I can't access/modify the way -s works 😞
$ perl -CASD -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=пÑивеÑ
x=пÑивеÑ
ARGV[0]=привет
$ perl -CASD -Mutf8 -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=пÑивеÑ
x=привет
ARGV[0]=привет
$ perl -CASD -Mutf8::all -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=пÑивеÑ
x=привет
ARGV[0]=привет
$ perl -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=привет
x=привет
ARGV[0]=привет
$ perl -Mutf8 -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
Wide character in print at -e line 1.
v=пÑивеÑ
x=привет
ARGV[0]=пÑивеÑ
$ perl -Mutf8::all -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=пÑивеÑ
x=привет
ARGV[0]=привет
I don't think this can be fixed. And quite frankly, people shouldn't be using -s anyway, it's not a particularly good argument parser. Getopt::Long has been the most popular argument parser for more than two decades, and there are several other competent options.
I also thought it was something like a bug in perl. I think it should work with -CA option. Maybe it is necessary to send a bug report, but I don't really use perl very often.
@Leont It's not for perl scripts. This method, like the corresponding option in awk, is used to pass arguments from the shell script to the perl command used in the script. It's just a way to avoid a nightmare with single and double quotes.
I use perl instead of sed and awk because of perl regular expressions.