Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Detect the Charset of an file

by mtmcc (Hermit)
on Oct 21, 2013 at 13:45 UTC ( [id://1059111]=note: print w/replies, xml ) Need Help??


in reply to Detect the Charset of an file

Encode::Guess might be worth a look; as may this previous posting: What encoding am I (probably) using?

Replies are listed 'Best First'.
Re^2: Detect the Charset of an file
by endymion (Acolyte) on Oct 22, 2013 at 07:12 UTC
    Hello again, I tried the code: $d = new Encode::Detect::Detector; $d -> handle($file); ($file is my textfile) $charset = $d->getresult; print "*".$charset."*\n"; I'm getting: Undefined subroutine &main::handel called at .....
      The string "handel" doesn't appear in the code you posted -- in other words you didn't copy/paste your code with typos
        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 :-)
        use Encode::Detect::Detector; $d -> new Encode::Detect::Detector; $d -> handle($file) $charset = $d -> getresult;
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1059111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found