1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#!/usr/bin/perl -w
use strict;
use Unicode::String;
###########################################
#
# 2UTF8.pl
# ________
#
#Pour la conversion de fichiers ISO-8859-1
#vers UTF-8
#INPUT : un fichier ASCII ISO-8859-1
#OUTPUT : un fichier ASCII UTF-8
###########################################
Unicode::String->stringify_as('utf8');
my($file) = $ARGV[0];
my($file_dest) = $file.".new";
open FILE, "< $file" or die "$!\n";
open FILE2, "> $file_dest" or die "$!\n";
while(<FILE>){
$_ = Unicode::String::latin1($_);
print FILE2 $_;
}
close FILE and close FILE2;
unlink $file;
rename($file_dest, $file);
unlink $file_dest; |
Partager