How to interpret user input of escape character?
<p>User inputs a value such as <code>\n</code>, <code>\t</code>, <code>\r</code> etc </p>

<p>Java of course escapes the above characters with a backslash. So the application has the following Strings in the buffer </p>

<p><code>\\n</code>, <code>\\t</code>, <code>\\r</code> </p>

<p>Now how do I convert those Strings back into <code>\n</code>, <code>\t</code>, <code>\r</code> </p>

<p>I could write an <code>switch</code> statement. But there is unlimited number of options </p>

<p>What if a user enters some unicode character <code>\u1010</code> ? </p>

<p>This doesn't work <code>userInput.replaceAll("\\\\", "\\")</code> </p>

<p><strong>How to interpret user input of escape character?</strong> </p>