2 replies [Last post]
rmfred
rmfred's picture
Offline
Elder
Rock Springs, WY
Last seen: 2 years 3 weeks ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

How do you all keep track of the various sgml characters and keep your xhtml pages validating?
The reason I ask is this: I allow some users to post news and updates to a site using a form. Every once in a while they will use an ampersand or some other character and then the page no longer validates as xhtml strict. This is not a HUGE problem because all the news and updates have an expiration date and the query that displays them deletes them based on the expiration date, but for the days that they are allowed to display, the page(Drunk don't validate.

I do my coding in notepad, and I can use an apostrophe.. for example in the word That's and the code validates... but it seems like if a user cuts and pastes from an email app or from MS Word and what they paste into the form contains an apostrophe or other character then the page(Drunk do not validate.

Do email apps and Word do weird things with characters.

Inquiring minds want to know Smile

Tags:
Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 2 days 18 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

xhtml validation and sgml characters

Hi rmfred,
You can use php functions such as htmlentities to clean up text entered by users.
Or if you are hand coding html check a table like http://www.ascii.cl/htmlcodes.htm

Word and some email apps do funny things to characters, or use characters not part of the ISO 8859-1 standard.
http://www.cs.tut.fi/~jkorpela/www/windows-chars.html

rmfred
rmfred's picture
Offline
Elder
Rock Springs, WY
Last seen: 2 years 3 weeks ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

xhtml validation and sgml characters

Thanks Tony; that confirmed my suspicions of email apps and word doing strange things to characters... I use vbscript /asp so I am tring to write a regular expression to take care of this