in reply to Re: Re: Re: Reading and writing to unicode files
in thread Reading and writing to unicode files

No byte markers, it really looks as if it's just taking two bytes per character, rather than one. SO I tried to break it down to an even more basic level, with the following:
open (READ, "<:encoding(UCS2)", "z:/test.txt") or die "unable to open +file"; foreach (<READ>) { print $_; }
with test.txt being a copy of the config file I'm trying to open. (BTW, UCS2 fails with quite glorious results, involving much beeping :))

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Reading and writing to unicode files
by iburrell (Chaplain) on Mar 05, 2004 at 18:49 UTC
    You need to figure out the byte-order with UCS-2 and UTF-16. If there is no BOM, then Encode::Unicode can't figure it out. Windows is almost certainly little-endian, so try UTF-16LE. Also, "UCS-2" means "UCS-2BE" to Perl. That is probably the wrong byte order.