I'm trying to find out what encoding has been used on a file. It was created in a text editor under OS9, but edited also under OSX, the scripe below outputs:

Encode::XS=SCALAR(0x94a2c), which when de-reffed is '2421076'

I'm none the wiser.

Robin



#!/usr/bin/perl -w

#=========== declare includes =============

use strict;
use diagnostics-verbose;

#========== declare variables =============

my($DataFileName,$LocalPath,$data,$enc,$in,$infile,$out,$outfile);
#============= script body ================



use Encode;
$LocalPath= $ENV{HOME}.'/Desktop';
$DataFileName='j-indexText.html';

$infile = join ('/',$LocalPath,$DataFileName);
$outfile = join ('.',$infile,"parsed");


open (IN, $infile) or die; $data=<IN>;



use Encode::Guess qw/euc-jp shiftjis 7bit-jis /;

$enc = guess_encoding($data, qw/euc-jp shiftjis 7bit-jis MacJapanese utf8 /);
ref($enc) or die "Can't guess: $enc"; # trap error this way


print ${enc};



Reply via email to