To generate ascii values and feed $bitmask
I use:
perl -E 'say chr 101' > value_ascii.txt
My question comes up when I try to generate an ascii value for the number 1185644
. That is, now I want the value of $bitmask
to be the ascii value corresponding to the numeric value 1185644
.
If I use perl -E 'say chr 1185644' > ascii_expected.txt
the value obtained by I don't get the correct range from 1185644 nth subset to 1185744 nth subset. So I think the conversion perl -E 'say chr 1185644' > ascii_expected.txt
is not working.
I have been trying to correctly acquire the ascii value of 1185644 by doing:
perl -E 'say chr 1185644' > ascii_expected.txt
but what is printed:
ô¡<0x9d>¬
and get error:
Wide character in say at -e line 1.
I tried to understand how to use it:
sub nice_string {
join("",
map { $_ > 255 # if wide character...
? sprintf("\\x{%04X}", $_) # \x{...}
: chr($_) =~ /[[:cntrl:]]/ # else if control character...
? sprintf("\\x%02X", $_) # \x..
: quotemeta(chr($_)) # else quoted or as themselves
} unpack("W*", $_[0])); # unpack Unicode characters
}
nice_string("foo\x{1185644}bar\n")
but I couldn't
Does not seem to be the correct value.
I tried to do:
use open OUT => ':locale';
open(O, ">koi8");
print O chr(1185644);
close O;
but my output print to file is:
\x{12176C}
and get error:
Code point 0x12176C is not Unicode, may not be portable in print at p1.pl line 3.
Note: I expect an ascii_value
for 1185644 such that I can use it as a variable like for example $b = 'ascii_value';
in perl.