|
|
Question : Change file encoding to ansi from utf8 (Win2k)
|
|
Hi,
firstly, this is a windows-perl (activestate) question (not real *nix perl=)
I have a text file that has been encoded in utf-8 format. I want to make my perl script recognise that the file is in utf-8 format, and change the contents to ansi.
Not easy. But I reckon it can go one of three ways.
1. Try to get Windows to do it (execute a windows command of some sort)?
2. Get perl to change the encoding of the file as a whole?
3. Get perl to read in the contents as utf-8 - and convert to ansi?
Personally, I think 3 is more likely. If anyone can tell me exactly what I need, and perhaps even an example, I would really appreciate it!
I have been looking at loads of modules, but have had trouble getting them to work as I intend!
Thank you very much for your help. Best regards,
|
Answer : Change file encoding to ansi from utf8 (Win2k)
|
|
thought I'd just give you another quick tip, which worked for me in a certain setting:
use Unicode::String qw/ utf8 latin1/;
# supposing $input contains utf8 data, this should transform it to latin1, # which is fairly close to ansi)
$output = latin1( utf8( $input) ) ;
I also found some references in the XML::Twig manual about Encode, and Text::iconv. Also, Unicode::Map seems to contain quite some mappings. You might want to check those out on CPAN.
HTH
|
|
|
|
|