set_encoding (private, deprecated)
set_encoding [ -text_translation text_translation ] content_type \
channelDefined in packages/acs-tcl/tcl/deprecated-procs.tcl
Deprecated. Invoking this procedure generates a warning.
The ad_http* and util_http* machineries depend on the AOLserver/NaviServer socket I/O layer provided by [ns_sockopen]. This proc allows you to request Tcl encoding filtering for ns_sockopen channels (i.e., the read and write channels return by [ns_sockopen]), to be applied right before performing socket I/O operations (i.e., reads).
The major task is to resolve the corresponding Tcl encoding (e.g.: ascii) for a given IANA/MIME charset name (or alias; e.g.: US-ASCII); the main resolution scheme is implemented by [ns_encodingfortype] which is available bother under AOLserver and NaviServer (see tcl/charsets.tcl). The mappings between Tcl encoding names (as shown by [encoding names]) and IANA/MIME charset names (i.e., names and aliases in the sense of IANA's character sets registry) is provided by:
- A static, built-in correspondence map: see nsd/encoding.c
- An extensible correspondence map (i.e., the ns/charsets section in config.tcl).
[ns_encodingfortype] introduces several levels of precedence when resolving the actual IANA/MIME charset and the corresponding Tcl encoding to use:
References:
- The "content_type" string contains a charset specification, e.g.: "text/xml; charset=UTF-8". This spec fragment takes the highest precedence.
- The "content_type" string points to a "text/*" media subtype, but does not specify a charset (e.g., "text/xml"). In this case, the charset defined by ns/parameters/OutputCharset (see config.tcl) applies. If this parameter is missing, the default is "iso-8859-1" (see tcl/charsets.tcl; this follows from RFC 2616 (HTTP 1.1); Section 3.7.1).
- If neither case 1 or case 2 become effective, the encoding is resolved to "binary".
- If [ns_encodingfortype] fails to resolve any Tcl encoding name (i.e., returns an empty string), the general fallback is "iso8859-1" for text/* media subtypes and "binary" for any other. This is the case in two situations:
- Invalid IANA/MIME charsets: The name in the "charset" parameter of the content type spec is not a valid name or alias in IANA's character sets registry (a special variant would be an empty charset value, e.g. "text/plain; charset=")
- Unknown IANA/MIME charsets: The name in the "charset" parameter of the content type spec does not match any known (= registered) IANA/MIME charset in the MIME/Tcl mappings.
- http://www.mail-archive.com/aolserver@listserv.aol.com/msg07261.html
- http://sourceforge.net/tracker/?func=detail&atid=103152&aid=932459&group_id=3152
- http://sourceforge.net/tracker/index.php?func=detail&aid=962233&group_id=3152&atid=353152
- Switches:
- -text_translation (optional, defaults to
"auto binary")- Parameters:
- content_type (required)
- channel (required)
- Author:
- stefan.sobernig@wu.ac.at
- Testcases:
- No testcase defined.