I have a textarea, and inside of it, I would like to be able to input text alongside escape sequences.
For example, lets say that inside the textarea is:
Hello\nWorld.
Now, If I wanted to print that value to the console by using:
console.log( document.getElementById('myTextArea').value )
The output that I would like would be:
Hello
World
But instead, it outputs:
Hello\nWorld
This makes since, because that's what I put in. But I would like to convert these sequences to their actual values
Now I'm sure this is possible with a simple string replace, like:
str.replaceAll('\\n', '\n')
But I would like to be able to do this with ANY escape sequence. like:
\u0000, \r, \u0020
So is it possible to extract these sequences from a textarea?
Like @James already mentioned in his comment, the answer to this question can be found here: How do I decode a string with escaped unicode?
So, the following snippet should not be seen as an answer, but rather as a demo of how to apply the method described there on two
textareafields.