in reply to writing utf8 files under WindowsXP

Assuming your source is a character set that shows the correct characters for above-128 codes, you're probably using windows-1250 or simmilar.

So you should probably replace the loop with:

while (<IN>) {from_to($_,"cp1250", "utf8"); print OUT $_;}

Replies are listed 'Best First'.
Re: Re: writing utf8 files under WindowsXP
by Anomynous Monk (Scribe) on Apr 28, 2004 at 18:50 UTC
    That will change $_ to contain utf8 data but not be marked by perl as utf8; so if you do that, binmode OUT and omit the ":utf8" on open.
Re: Re: writing utf8 files under WindowsXP
by snaporaz (Acolyte) on Apr 28, 2004 at 21:00 UTC
    Sorry for my ignorance: I tried your suggestion:
    while (<IN>) {from_to($_,"cp1250", "utf8"); print OUT $_;}
    but it complains about from_to, and I do have "use Encode" at the top of the script. What else does from_to need? Thanks
      You need to use Encode like this:
      use Encode qw/from_to/; ... from_to( $_, "cp1250", "utf8" ); ...
      Alternatively, you could use it like this:
      use Encode; ... Encode::from_to( $_, "cp1250", "utf8" ); ...
      This is because by default, Encode does not export the "from_to" function into the "main" namespace of your script.
        Thanks a lot to all for your help. Now I got my script working.