in reply to Re^2: Detect the Charset of an file
in thread Detect the Charset of an file

The string "handel" doesn't appear in the code you posted -- in other words you didn't copy/paste your code with typos

Replies are listed 'Best First'.
Re^4: Detect the Charset of an file
by endymion (Acolyte) on Oct 22, 2013 at 07:24 UTC
    Sorry that's not possible for me. I'm working on 2 machines in our company. My "internet" Computer is not my progamming one. I wanted to write "handle" not handel :-)

      Sorry that's not possible for me....

      Sure it is, until you're able to copy/paste the code you're trying to run, its going to be near impossible for someone to help you point our your real typos in your real code

Re^4: Detect the Charset of an file
by endymion (Acolyte) on Oct 22, 2013 at 08:10 UTC
    use Encode::Detect::Detector; $d -> new Encode::Detect::Detector; $d -> handle($file) $charset = $d -> getresult;
Re^4: Detect the Charset of an file
by endymion (Acolyte) on Oct 22, 2013 at 08:32 UTC
    No I'm not copying from the Encode site. Hmm very strange, I'm trying again and now I did'nt get any error. The problem is I can't post the whole script, because it's not allowed in our company. $file is an XML File whit characters like cech language. The XML Files are already in utf8 coded. In our conversion script we have an recode for all file from lat1 to utf8. Normally when the source file is already utf8 it should not recode the file, but the recode ist also running when the source file is utf8. Very strange.

      The problem is I can't post the whole script, because it's not allowed in our company.

      You don't have to post the whole script, simply post something sequivalent that demonstrates the problem you encounter -- replicate the problem with fewer lines of code

      So far its all been syntax errors

      Here is what I "wrote" by copy/pasting from http://p3rl.org/Encode::Detect::Detector

      #!/usr/bin/perl -- use strict; use warnings; use Encode::Detect::Detector; use autodie qw/ open /; my $octets = 'abc'.chr(266).chr(666); my $filename = shift || \$octets; open my($infh), '<:raw', $filename ; my $d = new Encode::Detect::Detector; while(my $line = readline $infh ){ $d -> handle( $line ); } $d -> eof; close $infh; my $charset = $d->getresult; print "**$filename gots *".$charset."*\n";
      __END__ **SCALAR(0x3f8fac) gots *UTF-8* </c>