Re: XML Filters for illegal characters
| From: | Jones, Douglas 1 | Date: | Wed, 05 Jan 2005 21:04:37 +0000 |
| Subject: | Re: XML Filters for illegal characters | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-205690@lists.php.net to get a copy of this message | ||
>Perhaps I am misunderstanding your problem, so let me ask it another
>way. Is the problem that you are getting characters entered into the
>database that are encoded in one way (e.g. UTF-8) when you expected the
>characters to be encoded in another way (e.g. ISO-8859-1)?
No, the problem involves characters in the text that are Illegal XML characters much like
"&" is an Illegal XML character. Only, the one the character that my software is
reporting as illegal is apparently not one that is caught by the normal filters (like htmlentities
or even some functions specifically coded for XML that I found on the PHP.net website). I think the
problem with the filters that I have tried is that they only attempt to change entities that are can
be encoded to something XML safe. Ideally, what I want is something that just removes the offending
character if it cannot make it safe for XML. So, say & is made into & but an unexpected
symbol is simply removed. For example (suppose "^" is a symbol that cannot be encode for
this example):
input: "str&ing"
output: "str&ing"
input: "str^ing"
output: "string"
I hope this makes things clear. I think that a function just like htmlentities but one that just
removes characters that are illegal but can not be fixed would be the ideal solution.
If anyone needs further clarification, I would be happy to try to provide it.
--
Doug Jones
Co-Op Web Developer
douglas.1.jones@lmco.com