In your HTML document:
- Use
ACCEPT-CHARSET
attribute with<FORM>
tag as prescribed by RFC 2070, it must contain a comma-separated list of character sets acceptable by the server (exactly as in theAccept-Charset
header field format but without anyq=
quality parameters, see How to request KOI8-R documents). - Use
POST
method, it is impossible to determine character set forGET
method arguments. - The
ACCEPT-CHARSET
attribute affects all<INPUT>
and<TEXTAREA>
elements of the<FORM>
. If you want a different character set for each element, you must use aENCTYPE=multipart/form-data
form, check out Form-based File Upload in HTML (RFC 1867) for more info.
For example:
<FORM METHOD=POST ACCEPT-CHARSET="koi8-r,us-ascii"
ACTION="cgi-bin/guestbook.cgi">
In your CGI script:
- Conformant browser must supply the
charset=name
attribute in theContent-Type
header field. For example:Content-Type: application/x-www-form-urlencoded; charset=KOI8-R
The value of this header field is accessible in a CGI script via the
CONTENT_TYPE
environment variable. You can check your browser with this<FORM>
input test. If a character set is present in the variable, extract it and pass as an argument to your external document character sets convertor.Another standard variant is using
ENCTYPE=multipart/form-data
, but in this case your browser must accompany each part of the multipart form data with the correctcharset=name
in theContent-Type
field. I don't know of any browser to comply to this requirement, so you should avoid using thisENCTYPE
value. - If the character set not provided by the variable, assume it is the same as specified in
ACCEPT-CHARSET
<FORM>
attribute and pass it to character sets converter.
WARNING: this works only for a single character set inACCEPT-CHARSET
attribute.