note 27018 deleted from function.htmlentities by nlopess
| From: | nlopess@php.net | Date: | Sun, 12 Sep 2004 14:58:58 +0000 |
| Subject: | note 27018 deleted from function.htmlentities by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76534@lists.php.net to get a copy of this message | ||
Note Submitter: Lars at dybdahl dot dk
----
If you ever plan to support more than ISO8859-1 characters, you should stop using htmlentities()
right now. Instead, you should:
1) Use htmlspecialchars() whereever you use htmlentities()
2) Add the character encoding you use to your html file:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
This will make sure that all characters reach the end-user of your webpages unharmed. When you
change to UTF-8, use the mb_strlen instead of strlen etc., make sure your text is in utf-8
everywhere, and use this one instead in the <head> section of your html file:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
In case you use XHTML instead of old HTML, please note that the character encoding is also specified
in the xml header. Replace this:
<?xml version="1.0" encoding="iso-8859-1"?>
with this:
<?xml version="1.0" encoding="utf-8"?>