Lowell Allen wrote:


On Apr 16, 2004, at 3:40 AM, Merlin wrote:


Hi there,

I am just validating html generated by a php page. There is an error which comes
up if ther is a dash in the content text. Those characters come out of a database.
Is there a command in php which is escaping those characters for valid html output?
Something like urlencode, but for text escaping all such signs?


Here is the error msg: non SGML character number 150
This is the text: normal – text


If the text is coming from a database, how did the invalid character get into the text in the first place? It sounds like the problem is with the original HTML editor, not with PHP. For example, the current version of Adobe GoLive still uses the invalid code &#150; for an en dash (the valid code is &#8211;). A good reference chart for correct character entities is here -- <http://www.roselli.org/adrian/articles/character_charts.asp>.

You could set up str_replace() translations to correct invalid character entity codes before displaying.

--
Lowell Allen


hmm so you would suggest to save the entitty code directly to the database in the first place? What happens if I want to use the text for something else,
lets say print outs, or the entity code changes over the years, respectively the
browsers comming up with new technologies and dropping the old standards?


Another thing I do not understand concerning php, if this is that important, why
is there not a function who does this? something like ent_replace()? Do I have
to write a str_replace statement for all the entity characters? If yes, does
anybody already have such a code line? It sounds to me that this is like inventing
the wheel over and over again?

regards,

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to