I have an input.dat file with Unix LF encoding, I want my output file to be Windows CR LF with UTF-8 encoding using Perl. Currently this is how my code looks. How can I add CR to the existing LF in the file?
sub encodeUTF8 {
my $ProcVars = $_[0];
my $src = $_[1];
my $des = $_[2];
# open source file for reading
open(SRC,'<',$src) or die $!;
# open destination file for writing
open(DES,'>',$des) or die $!;
binmode DES;
print("copying content from $src to $des\n");
while (<SRC>) {
s/^\N{BOM}// if $. == 1;
print DES;
}
close(SRC);
close(DES);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.