I have one mod_perl2 app that outputs Latin-1 by default and another that outputs UTF-8 aka Unicode. I am sending the appropriate Content-Type headers, but how do I make sure Apache/mod_perl won't mangle my UTF-8 when it prints my text out to the browser?

When printing from perl to a file or STDOUT or CGI STDOUT, I am supposed to binmode the filehandle/STDOUT with a :utf8 layer. But if I do this under mod_perl I'll be binmoding STDOUT different for each application. Won't that royally screw things up? The docs for binmode say one should set it as soon as possible after opening the handle.

Besides, I'm not sure mod_perl2 even uses STDOUT. From what I understand it just intercepts print calls and handles them in some other way. So I'm not sure settign binmode on STDOUT has any relevance for mod_perl2.

I have had a frustrating experience trying to find answers on this. The mod_perl2 changefile notes "much better support for Unicode" but I could not find anything concrete in the docs, or if I did I did not undestand it. A search of mod_perl2 docs for Unicode turns up the changefile and a troubleshooting tip involving byte order marks.

I found a BINMODE in Apache2::RequestIO but it is part of the "TIE interface," which does not sound like what I am looking for, and it says "NoOP", which does not sound promising anyway.

Not much luck with Google or Usenet searches either.

Any help is much appreciated.


In reply to Unicode and mod_perl 2 by ryantate

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.