Patch for charset aware htmlentities()

From: Date: Mon, 21 May 2001 22:30:18 +0000
Subject: Patch for charset aware htmlentities()
Groups: php.dev 
Request: Send a blank email to php-dev+get-56146@lists.php.net to get a copy of this message
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.

Attachment: [application/x-gzip-compressed] wezent.diff.gz
« previous php.dev (#56146) next »