E
Eileen
Hi,
I have a text file with CTRL-M's. It is encoded as UTF16. When I try
to search for a string in this file, nothing is found. If I remove the
control-m's in vi, my search works. However, I cannot get the
control-m's to be removed using Perl. I've tried:
my $file= "myfile.xml";
while (<IN>) {
s/\cM//g;
}
and
my $file= "myfile.xml";
while (<IN>) {
s/\x{0x0D00}//g;
}
and
my $file= "myfile.xml";
while (<IN>) {
s/\^M//g;
}
and
while (<IN>) {
s/\cM//g;
}
all to no avail. I've tried it on Unix perl as well as Windows perl.
Again, I can remove the characters with vi (using s/^V^M//g).
Does anyone have any ideas on what to do? If I convert the file to
UTF8, the substitution and subsequent searches work. However, I have
several hundred files to deal with, and they are all encoded as UTF16.
Thanks,
Eileen
I have a text file with CTRL-M's. It is encoded as UTF16. When I try
to search for a string in this file, nothing is found. If I remove the
control-m's in vi, my search works. However, I cannot get the
control-m's to be removed using Perl. I've tried:
my $file= "myfile.xml";
while (<IN>) {
s/\cM//g;
}
and
my $file= "myfile.xml";
while (<IN>) {
s/\x{0x0D00}//g;
}
and
my $file= "myfile.xml";
while (<IN>) {
s/\^M//g;
}
and
while (<IN>) {
s/\cM//g;
}
all to no avail. I've tried it on Unix perl as well as Windows perl.
Again, I can remove the characters with vi (using s/^V^M//g).
Does anyone have any ideas on what to do? If I convert the file to
UTF8, the substitution and subsequent searches work. However, I have
several hundred files to deal with, and they are all encoded as UTF16.
Thanks,
Eileen