Forum Moderators: open

Message Too Old, No Replies

how to display character entity ( ) in a form textarea?

         

zollerwagner

6:47 am on Aug 18, 2005 (gmt 0)

10+ Year Member



I have a form textarea. A client wants to be able to enter   so they can control the layout some.

When I redisplay their text for editing, the   is looks like a normal space, which means the client can't see that it's really   character entity.

How do I get it to display as the character entity?

kaled

8:28 am on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure if this answers your question but   could be written as &nbsp if you want to display the entity text rather than the entity character.

Kaled.

zollerwagner

4:37 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



Thanks for the answer!

Yeah, that's what I did in the first message to get the   to appear.

As often happens, my mind was whirling last night working on this problem. The solution is pretty simple. Use:
htmlspecialchars($input)
before you display the data, and it will make the   appear.

In this case, I can use ENT_NOQUOTES, and I don't have to worry about the other characters that htmlspecialchars() tranforms:
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
''' (single quote) becomes ''' only when ENT_QUOTES is set.
'<' (less than) becomes '&lt;'
'>' (greater than) becomes '&gt;'