in reply to Re: how do I check encoding before opening FILEHANDLE
in thread how do I check encoding before opening FILEHANDLE

So if you know how the algorithm to figure out the encoding, you can open in byte mode, check the data, and binmode with the appropriate encoding layer.
Encode::Guess can be used to guess the actual encoding, but it shouldn't be neccessary (if you're lucky), as the xml file should specify the encoding, as in <?xml version="1.0" encoding="ISO-8859-1"?>

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^3: how do I check encoding before opening FILEHANDLE
by gaal (Parson) on Feb 18, 2005 at 08:41 UTC
    Well, it's easy but not utterly trivial, because if you open the file in the wrong encoding and compare stings or try a regexp, the comparison will fail. (And if you claim utf8 and it isn't, you have to catch an exception that will be raised).