What Happens To Escape Characters?

Discussion in 'ASP .Net' started by Guadala Harry, Aug 18, 2004.

  1. I'd like to know the answer to the following question so I can know what to
    expect with regard to other similar uses of escape characters and strings.
    While everything works fine - I'd like to know specifically why:

    I am building a simple HTML table in my C# code-behind by concatenating
    strings that contain different parts of the table and table content...
    something like this:

    string myTable = "<table width=\"100%\" border=\"0\" cellspacing=\"0\"
    cellpadding=\"0px\" class=\"myCSSClass\"><tr><td>";

    Notice the back-slash (\) character which is there to escape each of the
    double-quote (") characters.

    After the table is finished being constructed, it exists in one string
    variable - which I HtmlEncode prior to returning to the caller.

    The calling method then HtmlDecodes that string, and for testing purposes
    renders to the browser via Response.Write(). The table renders just
    beautifully. While that is good news, I'm curious as to what is happening to
    the \ escape characters. They are all present in the HtmlDecoded string, of
    course - which is fed into Response.Write(). The value of the string that
    shows up in the browser (i.e., the <table> definition) does *not* have the
    escape characters (at least as the browser shows the rendered page). So,
    when were they removed, and what removed them?

    In trying to determine where the escape characters are being removed (client
    or server side), I pasted the string value with the escape characters (the
    value that is fed to Response.Write()) directly into the ASPX file - and it
    failed to render correctly, as all of the escape characters were present.
    So, apparently the browser is not removing them. What specifically is
    removing them?

    Thanks!
    Guadala Harry, Aug 18, 2004
    #1
    1. Advertising

  2. The escape characters are removed once you compile the project.

    They are there to tell the compiler you really want to input a ' " ' and not
    to terminate the string, so no point to keep them after the project is
    built.

    "Guadala Harry" <> ¦b¶l¥ó
    news: ¤¤¼¶¼g...
    > I'd like to know the answer to the following question so I can know what

    to
    > expect with regard to other similar uses of escape characters and strings.
    > While everything works fine - I'd like to know specifically why:
    >
    > I am building a simple HTML table in my C# code-behind by concatenating
    > strings that contain different parts of the table and table content...
    > something like this:
    >
    > string myTable = "<table width=\"100%\" border=\"0\" cellspacing=\"0\"
    > cellpadding=\"0px\" class=\"myCSSClass\"><tr><td>";
    >
    > Notice the back-slash (\) character which is there to escape each of the
    > double-quote (") characters.
    >
    > After the table is finished being constructed, it exists in one string
    > variable - which I HtmlEncode prior to returning to the caller.
    >
    > The calling method then HtmlDecodes that string, and for testing purposes
    > renders to the browser via Response.Write(). The table renders just
    > beautifully. While that is good news, I'm curious as to what is happening

    to
    > the \ escape characters. They are all present in the HtmlDecoded string,

    of
    > course - which is fed into Response.Write(). The value of the string that
    > shows up in the browser (i.e., the <table> definition) does *not* have the
    > escape characters (at least as the browser shows the rendered page). So,
    > when were they removed, and what removed them?
    >
    > In trying to determine where the escape characters are being removed

    (client
    > or server side), I pasted the string value with the escape characters (the
    > value that is fed to Response.Write()) directly into the ASPX file - and

    it
    > failed to render correctly, as all of the escape characters were present.
    > So, apparently the browser is not removing them. What specifically is
    > removing them?
    >
    > Thanks!
    >
    >
    >
    Lau Lei Cheong, Aug 18, 2004
    #2
    1. Advertising

  3. Thanks - now just to be clear - this all has *nothing* to do with browsers
    or asp.net or html, and same would apply for any .NET project type?

    -G


    "Lau Lei Cheong" <> wrote in message
    news:%...
    > The escape characters are removed once you compile the project.
    >
    > They are there to tell the compiler you really want to input a ' " ' and

    not
    > to terminate the string, so no point to keep them after the project is
    > built.
    >
    > "Guadala Harry" <> ¦b¶l¥ó
    > news: ¤¤¼¶¼g...
    > > I'd like to know the answer to the following question so I can know what

    > to
    > > expect with regard to other similar uses of escape characters and

    strings.
    > > While everything works fine - I'd like to know specifically why:
    > >
    > > I am building a simple HTML table in my C# code-behind by concatenating
    > > strings that contain different parts of the table and table content...
    > > something like this:
    > >
    > > string myTable = "<table width=\"100%\" border=\"0\" cellspacing=\"0\"
    > > cellpadding=\"0px\" class=\"myCSSClass\"><tr><td>";
    > >
    > > Notice the back-slash (\) character which is there to escape each of the
    > > double-quote (") characters.
    > >
    > > After the table is finished being constructed, it exists in one string
    > > variable - which I HtmlEncode prior to returning to the caller.
    > >
    > > The calling method then HtmlDecodes that string, and for testing

    purposes
    > > renders to the browser via Response.Write(). The table renders just
    > > beautifully. While that is good news, I'm curious as to what is

    happening
    > to
    > > the \ escape characters. They are all present in the HtmlDecoded string,

    > of
    > > course - which is fed into Response.Write(). The value of the string

    that
    > > shows up in the browser (i.e., the <table> definition) does *not* have

    the
    > > escape characters (at least as the browser shows the rendered page). So,
    > > when were they removed, and what removed them?
    > >
    > > In trying to determine where the escape characters are being removed

    > (client
    > > or server side), I pasted the string value with the escape characters

    (the
    > > value that is fed to Response.Write()) directly into the ASPX file - and

    > it
    > > failed to render correctly, as all of the escape characters were

    present.
    > > So, apparently the browser is not removing them. What specifically is
    > > removing them?
    > >
    > > Thanks!
    > >
    > >
    > >

    >
    >
    Guadala Harry, Aug 18, 2004
    #3
  4. Yes unless your code is on any of the client side script, where they are
    sent as plain text to browsers and then get interpreted.

    "Guadala Harry" <> ¦b¶l¥ó
    news: ¤¤¼¶¼g...
    > Thanks - now just to be clear - this all has *nothing* to do with browsers
    > or asp.net or html, and same would apply for any .NET project type?
    >
    > -G
    >
    >
    > "Lau Lei Cheong" <> wrote in message
    > news:%...
    > > The escape characters are removed once you compile the project.
    > >
    > > They are there to tell the compiler you really want to input a ' " ' and

    > not
    > > to terminate the string, so no point to keep them after the project is
    > > built.
    > >
    > > "Guadala Harry" <> ¦b¶l¥ó
    > > news: ¤¤¼¶¼g...
    > > > I'd like to know the answer to the following question so I can know

    what
    > > to
    > > > expect with regard to other similar uses of escape characters and

    > strings.
    > > > While everything works fine - I'd like to know specifically why:
    > > >
    > > > I am building a simple HTML table in my C# code-behind by

    concatenating
    > > > strings that contain different parts of the table and table content...
    > > > something like this:
    > > >
    > > > string myTable = "<table width=\"100%\" border=\"0\" cellspacing=\"0\"
    > > > cellpadding=\"0px\" class=\"myCSSClass\"><tr><td>";
    > > >
    > > > Notice the back-slash (\) character which is there to escape each of

    the
    > > > double-quote (") characters.
    > > >
    > > > After the table is finished being constructed, it exists in one string
    > > > variable - which I HtmlEncode prior to returning to the caller.
    > > >
    > > > The calling method then HtmlDecodes that string, and for testing

    > purposes
    > > > renders to the browser via Response.Write(). The table renders just
    > > > beautifully. While that is good news, I'm curious as to what is

    > happening
    > > to
    > > > the \ escape characters. They are all present in the HtmlDecoded

    string,
    > > of
    > > > course - which is fed into Response.Write(). The value of the string

    > that
    > > > shows up in the browser (i.e., the <table> definition) does *not* have

    > the
    > > > escape characters (at least as the browser shows the rendered page).

    So,
    > > > when were they removed, and what removed them?
    > > >
    > > > In trying to determine where the escape characters are being removed

    > > (client
    > > > or server side), I pasted the string value with the escape characters

    > (the
    > > > value that is fed to Response.Write()) directly into the ASPX file -

    and
    > > it
    > > > failed to render correctly, as all of the escape characters were

    > present.
    > > > So, apparently the browser is not removing them. What specifically is
    > > > removing them?
    > > >
    > > > Thanks!
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Lau Lei Cheong, Aug 19, 2004
    #4
    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. Griff

    trying out escape characters

    Griff, Aug 3, 2004, in forum: Perl
    Replies:
    6
    Views:
    599
  2. Maziar Aflatoun

    Escape characters

    Maziar Aflatoun, Dec 5, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    544
    Jason S
    Dec 5, 2003
  3. =?Utf-8?B?YmFzdWxhc3o=?=

    Are there escape characters for SQL?

    =?Utf-8?B?YmFzdWxhc3o=?=, Jul 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    10,929
    Patrice
    Jul 7, 2005
  4. NM
    Replies:
    6
    Views:
    452
    Default User
    Sep 20, 2006
  5. slomo
    Replies:
    5
    Views:
    1,507
    Duncan Booth
    Dec 2, 2007
Loading...

Share This Page