in reply to help neeed in unpack

The line
$chinese=<INPUT>;
grabs only one line from the file. If you wrote 1 character per line, well, you'll just get 1 character.

Replies are listed 'Best First'.
Re^2: help neeed in unpack
by uva (Sexton) on Mar 14, 2006 at 11:48 UTC
    that file contains the sequence of four chinese characters in a line.it is getting the four characters , i have problem in unpack operation.
Re^2: help neeed in unpack
by uva (Sexton) on Mar 14, 2006 at 12:33 UTC
    i tried the following code.but still problem
    the input.txt contains 4 chinese characters in a line.
    use utf8; use Encode; open INPUT,"<:utf8","D:\\try_unicode\\input.txt" or die "Couldn't open + file: $!"; close STDOUT; open STDOUT ,">:utf8","D:\\try_unicode\\output.doc" or die "Couldn't o +pen file: $!"; $unpacking=<INPUT>; chomp($unpacking); print "\nunpacking1 :" ,decode("utf8",unpack("x4A4",$unpacking)),"\n +"; print "\nunpacking2 :" ,unpack("U4A4",$unpacking),"\n"; close INPUT; close STDOUT;
    i used U4 still its giving some sequence of numbers.
    i trien to x4 to null byte the four chinese characters its not working .
    i tried using A4 also its not working.
      I don't understand what you're trying to do with "unpack" here.