0

In my html page, I have a textarea tag and some text inside it. Later I will process the text.

<html>
    <body>
        <textarea name="" id="" cols="30" rows="10">
            test&#xA;test
        </textarea>

    </body>
</html>

But in the output html page '& #xA;' (adding a space to avoid character from being invisible ) is being replaced with a newline. I want to see those characters as character. Basically I want to escape that from being parsed.

I did a lot of research looked at html escape characters and did not find anything.

Also I looked at a SO question here and I want to do exact opposite.

You can look at the jsfiddle here

Is there any way to escape this character.

Thank you in advance.

Community
  • 1
  • 1
shreesha
  • 1,811
  • 2
  • 21
  • 30

2 Answers2

0

textarea is an escapable raw text element, so any sequence of characters inside it that starts with "&" (ampersand) and that ends with a semicolon gets parsed as a character reference.

So to prevent the &#xA; in the test&#xA;test code snippet in the question from being parsed as a character reference for the newline character, the "&" just needs to be replaced with &amp;:

test&amp;#xA;test
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
0

<html>
    <body>
        <textarea name="" id="" cols="30" rows="10">
            test&amp;#xa;test
        </textarea>

    </body>
</html>
rapaelec
  • 1,238
  • 12
  • 10