Hello,

I am trying to convert MacRoman encoded text to iso-8859-1. The script below show what I am trying to do.

The input file, data.txt contains the following string:

Les éléphants sont arrivés. €

When I run the script, I get the following string, which is utf-8 and not iso-8859-1, in the data2.txt file:

Les éléphants sont arrivés. €

I have tried adding the STDIN and STDOUT flags below, but to no avail. What am I doing wrong?

Furthermore, I keep getting a warning message about wide-characters, which makes sense, I think, because the output is UTF-8.

Many thanks.

Philippe


#!/bin/perl -w use strict;

use encoding "MacRoman"; #, STDIN => "MacRoman", STDOUT => "iso-8859-1";

open FH, "data.txt" or die "$!";
my $data = "";

while (<FH>) {
        $data .= $_;
}
close FH;

open FH, ">data2.txt" or die "$!";
print FH "$data";
close FH;



Reply via email to