I'm new to Naviserver and I'm not quite sure about the intended use of ns_conn
encoding.

There are three situation where it is possible to change the encoding by hand:

1. When using ns_write, you can set the encoding with ns_startcontent
-type. You could also use ns_conn encoding, but ns_startcontent was
designed only for this purpose, so i think it would be better to use
this function.

2. Inside adp-files one can use ns_conn encoding. But it is necessary
to change the Content-Type-Header explicitly. The function
ns_adp_mimetype will set the Content-Header and change the encoding,
so the use of this function is easier and less dangerous.

3. ns_return expects a type-argument which will be used to create the
Content-Type-Header. If you specify a charset, naviserver will
automatically load the corresponding tcl-encoding. So here you have
also no need to change the encoding with ns_conn encoding (btw if you
do so, the result is very confusing).

For me it looks like the use cases for ns_conn encoding are rare, e.g.
if you use it in a context where the client knows exactly what encoding to
expect. The documentation should mention the above alternatives and warn not
to use ns_conn encoding if you "don't know all side effects."

Michael

Reply via email to