Reverse escaping in HTML

Discussion in 'HTML' started by Csaba2000, Jan 17, 2004.

  1. Csaba2000

    Csaba2000 Guest

    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
    questions).

    Thanks for any tips,
    Csaba Gabor
    Csaba2000, Jan 17, 2004
    #1
    1. Advertising

  2. Csaba2000

    Brian Guest

    Csaba2000 wrote:
    > 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'>


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

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

    > I'm after a generic solution, if possible, as the above example is
    > a fairly simplistic illustration.


    I don't know what you mean by that.

    > In addition, I may want to encode other characters such as the alt
    > itself


    The alt itself? What is that?

    > or the symbols such as the "less than"


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

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

    (I must be misunderstanding you.)

    > or "equal" sign (so this might actually be two questions).


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

    --
    Brian
    follow the directions in my address to email me
    Brian, Jan 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Nentwig

    JSP2/EL: escaping HTML

    Timo Nentwig, Apr 29, 2004, in forum: Java
    Replies:
    0
    Views:
    341
    Timo Nentwig
    Apr 29, 2004
  2. Timo Nentwig

    EL: escaping HTML

    Timo Nentwig, May 8, 2004, in forum: Java
    Replies:
    4
    Views:
    7,767
    Timo Nentwig
    May 10, 2004
  3. Jim Bancroft

    help w/HTML escaping in XML tags?

    Jim Bancroft, Mar 2, 2005, in forum: XML
    Replies:
    5
    Views:
    1,109
    Peter Flynn
    Mar 6, 2005
  4. dogbite
    Replies:
    4
    Views:
    681
    osmium
    Oct 10, 2003
  5. Alan Silver
    Replies:
    6
    Views:
    495
    Alan Silver
    Jun 12, 2006
Loading...

Share This Page