Hi , I am using the Encode module (perl 5.8)to convert a string from utf8 to big 5. There is something that I do not understand that I thought you may help with: The input to the program is a file that contains a utf8 string, The encoding works properly only when I use the following code: use Encode qw(encode decode find_encoding from_to);
$file = shift; open my $in, $file; while ($str = <$in>) { chomp; open my $in1, "<:encoding(utf8)", \$str; while (<$in1>) { $octet = encode("utf8", $_); from_to($octet, "utf8","big5"); print "$octet\n"; } } close $in; what I dont understand is two things: 1.why do I need to read the string using IO ( open my $in1, "<:encoding(utf8)", \$str;) 2.why do I need to use the encode function before the from_to function($octet = encode("utf8", $_);) I thought that the bellow code will convert correctly but it does not: use Encode qw(encode decode find_encoding from_to); $file = shift; open my $in, $file; while ($str = <$in>) { chomp($str); from_to($octet, "utf8","big5"); print "$octet\n"; } close $in; Thank you Dana