Hi,
Encode::Guess does a fine job to detect the encoding. Read its documentation carefully on CPAN. To detect the encoding you can use something like:
open ( IN, "<", yourfile); my $bigstring = ""; my @content = <IN>; foreach my $tmp (@content) { $bigstring .= $tmp; } print "My file content encoding is: ", Encode::Guess->guess($bigstring +)->name;
Now you can decode and encode your data in the encoding you want. You need to have a strategy as to this matter. I recomment keeping it in UTF8 or 16 depending on the case. If you face BOM issues String::BOM is a good solution.
The following might help further: http://perldoc.perl.org/perluniintro.html
K
In reply to Re^2: How do you open/read a text , without knowing its encoding, and remove any BOM if its utf, what do you use?
by Zzenmonk
in thread How do you open/read a text , without knowing its encoding, and remove any BOM if its utf, what do you use?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |