pack and unpack question for perl 5.8.0

T

Tulan W. Hu

My old perl code has the following that works in 5.6.0:
while($line = <STDIN>){
chomp $line;
$aline = $line;

($tline = $aline) =~ tr/\0-\x{ff}//UC;
printf STDERR ("%s\n", $tline);
}

I changed it for perl 5.8.0
while($line = <STDIN>){
chomp $line;
$aline = $line;

$pline = pack("C*", unpack("U*", $line));
printf STDOUT ("%s\n", $pline);
}

Both codes give me the same output if I use perl 5.6.0.
However, if I use perl 5.8.0, then the output is the same
as the input.
The code is converting utf8 to latin1.
I'm wondering which output is correct.

Thanks for your help in advance!
Tulan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top