Branch: Tag:

2004-06-30

2004-06-30 13:02:00 by Stefan Wallström <stewa@roxen.com>

Auto decode a lot of more charsets.

Rev: server/base_server/prototypes.pike:1.143
Rev: server/etc/modules/Roxen.pmod:1.183
Rev: server/protocols/ftp.pike:2.101

6:   #include <module.h>   #include <variables.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.142 2004/06/28 17:48:22 mast Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.143 2004/06/30 13:01:59 stewa Exp $";    -  + constant magic_charset_variable_placeholder = "UTF-8"; +    #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)   #else /* !DAV_DEBUG */
1451:    }    }    +  array replace_charset_placeholder(string charset, string what, int allow_entities) { +  // If we allow entities we also replace the automatic charset placeholder with the charset in use +  if(allow_entities && charset) +  what = replace(what, magic_charset_variable_placeholder, charset); +  // Dependency problem here using Roxen.magic_charset_variable_placeholder +  return ({ charset, what }); +  } +     array(string) output_encode(string what, int|void allow_entities,    string|void force_charset)    {
1459:    if (String.width(what) == 8) {    if (force_charset) {    if (upper_case(force_charset) == "ISO-8859-1") -  return ({ "ISO-8859-1", what }); +  return replace_charset_placeholder("ISO-8859-1", what, allow_entities);    } else {    if (sizeof(output_charset) == 1 &&    upper_case(output_charset[0]) == "ISO-8859-1") -  return ({ "ISO-8859-1", what }); +  return replace_charset_placeholder("ISO-8859-1", what, allow_entities);    }    }   
1480:    }    if (encoder)    what = encoder(what); -  return ({ charset, what }); +  return replace_charset_placeholder( charset, what, allow_entities );    } else    return ({    0,