note 65702 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:56:32 +0000 |
| Subject: | note 65702 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154915@lists.php.net to get a copy of this message | ||
Note Submitter: cameron at prolifique dot com
----
I've been dissatisfied with all the solutions I've yet seen for converting text into html
entities, which all seem to have some drawback or another. So I wrote my own, borrowing heavily from
other code posted on this site.
http://www.prolifique.com/entities.php.txt
makeSafeEntities() should take any text, convert it from the specified charset into UTF-8, then
replace all inappropriate characters with appropriate (and legal) character entities, returning
generic ISO-8859 HTML text. Should NOT reconvert any entities already in the text.
makeAllEntities() does the same, but converts the entire string to entities. Useful for obscuring
email addresses (in a lame but nonetheless somewhat effective way).
Suggestions for improvement welcome!