First, you're not getting 00, you're getting
Missing argument in sprintf at a.pl line 19, <DATAFILE> line 1. Character: 00
The root of the problem is
my @list = unpack( 'A' x length($string), $string );
"A" trims trailing whitespace, and that includes newlines. You want "a".
my @list = unpack( 'a' x length($string), $string );
or better yet
my @list = unpack( '(a)*', $string );
So,
while (<DATAFILE>) { for my $ch (unpack('(a)*', $_)) { printf "Character:\t%s\t%2.2x\n", $ch, ord($ch)); } }
or
while (<DATAFILE>) { for my $ord (unpack('C*', $_)) { printf "Character:\t%s\t%2.2x\n", chr($ord), $ord); } }
PS - The name of the encoding is UTF-16LE, not UTF16-LE.
In reply to Re: Why aren't spaces from a Unicode file converting to Hexadecimal value 20?
by ikegami
in thread Why aren't spaces from a Unicode file converting to Hexadecimal value 20?
by Isolder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |