Reverse escaping in HTML

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Most of the time when I think of escaping characters in HTML,
it's ensuring that I can print certain characters instead of havingt them
be interpreted by the HTML parser.  (eg.  I can have a less than sign
rendered by using "<" (without the quotes)).

But I want to go in the other direction.  I want to be able to encode
arbitrary characters so that when they arrive at the browser they're
interpreted correctly at the appropriate time.

So, for example, I'd like to be able to do something like (note the
inner single quote):
<img src="Dinner.jpg" alt='"He's eating like a horse", she said'>

I'm after a generic solution, if possible, as the above example is
a fairly simplistic illustration.  In addition, I may want to encode
other characters such as the alt itself or the symbols such as
the "less than" or "equal" sign (so this might actually be two

Thanks for any tips,
Csaba Gabor

Re: Reverse escaping in HTML

Csaba2000 wrote:
Quoted text here. Click to load it

<img src="Dinner.jpg" alt="&quot;He's eating like a horse,&quot; she

You can do it other ways, too; I do it this way, because it keeps my
attributes consistently double-quoted.

Quoted text here. Click to load it

I don't know what you mean by that.

Quoted text here. Click to load it

The alt itself? What is that?

Quoted text here. Click to load it

<img src="image.jpg" alt="n &lt; t">

<img src="image.jpg" alt="n < t">

(I must be misunderstanding you.)

Quoted text here. Click to load it

<img src="image.jpg" alt="e = m*c squared">

follow the directions in my address to email me

Site Timeline