P is for Practical | |
PerlMonks |
Re: Module to read - modify - write text files in any unicode encodingby moritz (Cardinal) |
on May 19, 2008 at 21:32 UTC ( [id://687471]=note: print w/replies, xml ) | Need Help?? |
Encode is "core" since perl 5.7.3 and handles pretty much any encoding you can think of. You should use it.
To write a file with a specific encoding, it's enough to do things like this:
(Update: I didn't see you already used that, sorry for the noise.) Guessing character encodings can be done with Encode::Guess, but it can never be done reliably. I know of no module that combines encoding guessing with file slurping, so it might be worth the effort. But don't roll any encoding handling code by hand, it's all been done before and properly tested. See perluniintro, perlunitut and perlunicode for details, I also wrote a short article on the subject. (Update: Fixed article link, thanks for reporting Rudif.
In Section
Seekers of Perl Wisdom
|
|