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)" );


In reply to Re: Saving Encoded Text by graff
in thread Saving Encoded Text by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.