httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject Re: Apache::Request, APR::Table and UTF8
Date Wed, 06 Oct 2004 01:03:30 GMT
Boris Zentner <bzm@2bz.de> writes:

[...]

> Perhaps it is better to split the byte into nibbles 0:3 for the
> charset and 4:7 for flags. 

Yes, more or less.  Here's what I've been toying with right now:

/** @brief libapreq's pre-extensible string type */
typedef struct apreq_value_t {
    const char    *name;    /**< value's name */
    apr_size_t     size;    /**< Size of data.*/
    unsigned char  flags;   /**< charset:3, tainted:1, reserved:2, apps:2 */
    char           data[1]; /**< Actual data bytes.*/
} apreq_value_t;

typedef enum {
    APREQ_CHARSET_UNKNOWN = 0,
    APREQ_CHARSET_ASCII   = 1,
    APREQ_CHARSET_UTF8    = 2,
    APREQ_CHARSET_UTF16   = 3,
    /* XXX: may add 4 additional charsets */
} apreq_charset_t;

#define apreq_value_get_charset(v) ((apreq_charset_t )((v)->flags & 7U)
#define apreq_value_set_charset(v,c) do {       \
    apreq_value_t *val = v;                     \
    val->flags = (val->flags & ~7U) | ((c) & 7U); \
} while (0)

#define apreq_value_is_tainted(v)  ((v)->flags &   8U)
#define apreq_value_tainted_on(v)  ((v)->flags |=  8U)
#define apreq_value_tainted_off(v) ((v)->flags &= ~8U)




> This gives more room for charsets

I don't want to move towards a Tower of Babel within apreq2.
Supporting a few major charsets should be ok.  What I'm trying 
to decide is how to map utf8 key-value pairs into the apreq_value_t
above.  Do we really need a dedicated perlutf8 flag, or can we
use APREQ_CHARSET_UTF8 - so that the apreq_value_t's data will 
be meaningful to non-perl apps?

-- 
Joe Schaefer


Mime
View raw message