Bug #688 Updated: HTML special characters switched to meta-ASCII in form input
| From: | Bug Database | Date: | Sat, 19 Sep 1998 04:56:20 +0000 |
| Subject: | Bug #688 Updated: HTML special characters switched to meta-ASCII in form input | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-1246@lists.php.net to get a copy of this message | ||
ID: 688
Updated by: jaakko
Reported By: whit@transpect.com
Status: Closed
Bug Type: MySQL related
Assigned To: jaakko
Comments:
The conversion from HTML entity é happens in the client browser.
Browsers interpret the HTML code and HTML entities. They display to
the user and then send the actual data as the form data, that means
the actual ISO-8859-1 é (e-acute), to the server. It is of course
encoded with application/x-www-form-urlencoded type of codes
during the transport, but this has nothing to do with the problem as
this encoding is again decoded in PHP. So your script gets the
actual data, not just some encoding.
There are several things you can now do to fix your system.
1) Store characters as characters in your database. Mysql by default
is binary safe, so you can store ISO-8859-1 as pure 8-bit encoding
(ie. no encoding) there. Why not do so and forget about the rest?
Actually this would help you also with the searches, as MySQL
knows by default how to do case-insensitive searches with ISO-8859-1
characters, so this way you can search with:
.... where field like '%PERCÉ%' ...
and find what you are looking for. I recommend this approach.
2) When printing the fields in the form, you can encode the & characters
in the fields, so that the browser does not decode them:
value="<? echo htmlspecialchars ($string) ?>"
but of course the browser also displays them as é to the user then.
3) You can encode them back in your code with some function of your
own in PHP. I still recommend option 1).
4) we could write a function to PHP that encodes non-ascii characters
with &# -codes rather than ISO-8859-1 names. I do not see the immediate
need, but it could be a good idea. I still recommend option 1) for you.
Full Bug description available at: http://ca.php.net/bugs.php3?id=688
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net