anything rather than binmode(); for output ???
Er, no. You got a problem with that?
There is at least one syntactic variant on the same basic activity (which is really a matter of specifying a PerlIO layer for output to a file handle), using the "open" statement in perl 5.8.x:
open( $fh, $mode, $name )
# where $mode can be something like:
# ">:utf8", ">:encoding(UTF-16BE)", ">:encoding(cp1252)", and so on
Refer to "perldoc Encode" for a way to get the list of
available encodings.
Also, if you're dealing with just utf8 encoding, there's the "-C" option flag (see "perldoc perlrun" in 5.8.x). You really only need to specify the ":encoding(...)" on a file handle for non-utf8 (non-ascii) character data, because the various choices with "-C" cover all scenarios for utf8 i/o.
update: From the way you stated your question, I don't know if you understood how "binmode()" is used to control character encoding on file handles. It's exactly equivalent to the "mode" usage in the "open" statement, minus the angle brackets -- e.g.: binmode( $fh, ":encoding(UTF-16BE)" ); |