develooper Front page | perl.perl5.porters | Postings from April 2008

Specify i/o encoding != code encoding in one-liner?

Thread Next
From:
Mark J. Reed
Date:
April 24, 2008 04:27
Subject:
Specify i/o encoding != code encoding in one-liner?
Message ID:
f60fe000804231009j7f815e2dp14422a9276a8c5e1@mail.gmail.com
How can I tell Perl that its standard/file input is, say, UTF-16,
without also having it also try to interpret its code as UTF-16?

Things I thought of:

1. Is there any way via -m/-M to specify the equivalent of this use decl?

use encoding UTF-8, STDIN => UTF-16LE, STDOUT => UTF-16LE;

2. Alternatively, will something like this work?

perl -e 'BEGIN { open ARGV, '<:encoding(UTF-16LE)', <&ARGV; } ... '

Any other suggestions?

-- 
Mark J. Reed <markjreed@gmail.com>

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About