Problems reading in "£" character from a file

S

Stephen Adam

Hi there,

I'm having problems when reading in the "£" character from a file, they all
get converted into u's with an accent (?). Can anyone tell me why this is
happening and how to avoid it, its got me very confused.

Just run this program and make sure you place a file the same directory
called test.txt with some pound signs (£) in it, they keep getting
mytseriously turned into accented u's.

Thanks

Steve

PS - I'm running Perl on a Windows XP platform if thats any help.




#!C:/Perl/bin/perl.exe -w


# This program will read a file in the same directory called test.txt into
the "$whole" variable and

# then print it out


use strict;



&Datain();


exit(0);



sub Datain(){

our $FILEHANDLE = "./test.txt";
my $whole;


open("FILEHANDLE") or
die ("Unable to open file $FILEHANDLE\n Program Quiting\n");

while(my $line = <FILEHANDLE>){
chomp $line; # Get rid of new line char
$line .=" "; # Put blank space instead
$line =~ tr/[A-Z]/[a-z]/; # Put line variable into lowercase
$whole .= $line;
}

print "$whole";
}
 
B

Ben Morrow

Stephen Adam said:
Just run this program and make sure you place a file the same directory
called test.txt with some pound signs (£) in it, they keep getting
mytseriously turned into accented u's.

This is not a perl problem, it is a problem with DOS windows being
stupid about character encodings. If you direct your output to a file
instead you should find that your £s are intact.

Ben
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top