07-24-2023, 02:17 AM
I am writing `JScript` to be run using `Windows Script Host`.
Say I have a simple string variable:
s1 = '\n'
I want to build `s2` from two separated chars: `\` & `n`.
**naively** I would like to do:
s2 = '';
s2 += '\\';
s2 += 'n';
But this of course lead to `s1 != s2`
Can I build `s2` in such way that it has the same **interpreted meaning** as `s1`?
### Example:
WScript.Echo("1\n2")
var s;
s += '1';
s += '\\';
s += 'n';
s += '2';
WScript.Echo(s)
I'd wish both `WScript.Echo()` to print exactly the same thing.
### Note
I'm well aware that this question seems **completely idiotic**. I would probably think the same had I read it without knowing all the details. I don't expect anyone to understand the purpose . just curious to see whether it is feasible or do I need to re-think the whole thing.
Say I have a simple string variable:
s1 = '\n'
I want to build `s2` from two separated chars: `\` & `n`.
**naively** I would like to do:
s2 = '';
s2 += '\\';
s2 += 'n';
But this of course lead to `s1 != s2`
Can I build `s2` in such way that it has the same **interpreted meaning** as `s1`?
### Example:
WScript.Echo("1\n2")
var s;
s += '1';
s += '\\';
s += 'n';
s += '2';
WScript.Echo(s)
I'd wish both `WScript.Echo()` to print exactly the same thing.
### Note
I'm well aware that this question seems **completely idiotic**. I would probably think the same had I read it without knowing all the details. I don't expect anyone to understand the purpose . just curious to see whether it is feasible or do I need to re-think the whole thing.