0

I have tow var looks like some string. but the output show unicode, and output1 show right charactor. All typeof is string.

        const output = stdout.match(/"dst":"(.*)"/)[1];
        log('xxx=>', output, typeof output);    // xxx=>, \u6536\u5230, string
        const output1 = '\u6536\u5230';
        log('xxx=>', output1, typeof output1); // xxx=>, 收到, string

1 Answer 1

2

\ characters have special meaning (they are escape sequences) in string literals in JS source code.

They don't have special meaning in external input.

Sign up to request clarification or add additional context in comments.

1 Comment

I guess the question becomes “how do you convert the string to JS escape sequences”?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.