Double-Escaped Unicode Javascript Issue
- by Jeffrey Winter
I am having a problem displaying a Javascript string with embedded Unicode character escape sequences (\uXXXX) where the initial "\" character is itself escaped as "\"
What do I need to do to transform the string so that it properly evaluates the escape sequences and produces output with the correct Unicode character?
For example, I am dealing with input such as:
"this is a \u201ctest\u201d";
attempting to decode the "\" using a regex expression, e.g.:
var out = text.replace('/\/g','\');
results in the output text:
"this is a \u201ctest\u201d";
that is, the Unicode escape sequences are displayed as actual escape sequences, not the double quote characters I would like.