Judging by Moritz' reply below, and both the HTTP and HTML links referenced, this is incorrect.

The 'Accept-Charset' HTTP header is useful when the client (ie browser) sends a request to the server, but it's not in the list of headers that are meaningful to the response (ie the content your CGI script sends back to the browser). You could include it anyway, but the browser will almost certainly ignore it, and because it's not in the HTTP standard, you run the risk of all sorts of interesting compatibility problems if some browsers do give it some proprietry meaning.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.2 for the list of headers that are meaningful in a HTTP response.

Then follow Moritz' advice. :-)

Update: There is a way for the browser to indicate which character encoding it used when it POSTed the form data to the server: it's a part of the multipart/mime specification (usable in the body of the HTTP request). See http://www.faqs.org/rfcs/rfc1521.html, section 7.1.1. Unfortunately, I think this data is optional, and apart from that I don't know how you'd get access to that information in your CGI script anyway! Any other monks care to help on that point?

--
use JAPH;
print JAPH::asString();


In reply to Re^4: UTF-8 or iso-8859-1 input to CGI.pm by wol
in thread UTF-8 or iso-8859-1 input to CGI.pm by thedi

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.