Branch: Tag:

2005-04-12

2005-04-12 17:04:20 by Anders Johansson <anders@roxen.com>

Made the output_charset handling a bit safer and added get_output_charset(). Also set output charset if provided in a result mapping. Coded by mast.

Rev: server/base_server/prototypes.pike:1.147

6:   #include <module.h>   #include <variables.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.146 2005/01/14 16:44:58 mast Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.147 2005/04/12 17:04:20 anders Exp $";      #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)
1386:    break;       case 2: // Join. +  if (sizeof (output_charset) && +  (!stringp (to) || !stringp (output_charset[0]))) +  error ("Can't join charsets with functions (%O with %O).\n", +  to, output_charset[0]);    output_charset |= ({ to });    break;    }    }    -  +  string|function(string:string) get_output_charset() +  { +  string charset; +  function(string:string) encoder; +  foreach( output_charset, string|function f ) +  [charset,encoder] = join_charset(charset, f, encoder, 0); +  return charset || encoder; +  } +     static string charset_name(function|string what)    {    switch (what) {
1447:    return ({ old, oldcodec }); // Not really true, but how to know this?    default:    // Not true, but there is no easy way to add charsets yet... + #if 1 +  // The safe choice. +  return ({"UTF-8", string_to_utf8}); + #else    return ({ charset_name(add), charset_function(add, allow_entities) }); -  + #endif    }    }   
1574:    string charset="";    if( stringp(file->data) )    { +  if (file->charset) +  // Join to be on the safe side. +  set_output_charset (file->charset, 2);    if (sizeof (output_charset) ||    has_prefix (file->type, "text/") ||    (String.width(file->data) > 8))