Re: [PHP-DEV] Patch for charset aware htmlentities()

2001-05-21 Thread Wez Furlong

I wrote:
> This patch has an impact on the wddx extension which needs to pass
> a NULL for the charset, which will in turn search the locale to
> determine which to use.

Ignore that part; the charsets are only used when the "all" parameter is
in
effect.

--Wez.



-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Patch for charset aware htmlentities()

2001-05-21 Thread Wez Furlong

Hi,

The attached patch is the result of my work today on htmlentities.
It provides a charset aware implementation that works for:

iso-8859-1 (latin1),
iso-8859-15 (latin9)
Windows-1252 (latin1 with MS extensions)
utf-8

I have added a third optional parameter to htmlentities() to allow the
user
to specify the charset.
If omitted and the build supports setlocale(), it tries to determine the
charset from the locale (pretty futile to be honest, but worth a go).
If it can't determine to charset, or none is supplied, it defaults to
latin1.

I didn't really want to add the optional parameter, but setlocale() sucks
and an ini option didn't seem appropriate to something that could
theoretically be changed multiple times per script.

If the charset is utf-8, it unpacks the utf-8 encoding and uses the
latin1
entities if any match.

I've rewritten the entity substitution code so that multiple tables can
be
used for different character ranges and shared between charsets (eg:
cp1252
and utf-8 use the same table for the latin1 range).

This patch has an impact on the wddx extension which needs to pass a NULL
for the charset, which will in turn search the locale to determine which
to
use.
It might be a good idea to define a magic charset value that means "use
the
default latin1 tables"
#define HTML_ENTITY_LATIN1_CHARSET  (char*)(-1)
or just pass "iso-8859-1" instead of NULL.

Any comments?

--Wez.


 wezent.diff.gz

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]