How to? Riddle: How to echo > into a file?

Dec 10, 2014
63
1
#1
I've got some strings containing < and > located in strings and would like to echo-redirect them into a file (encoded as latin, not utf16 as filewrite seems to insist to do):

setdos /x-6
set sting=test1<test2>test3
setdos /x+6
echo %string > file.txt

This doesn't work, the < and > inside the variable get interpreted as redirection. Is there any way to do this? Thanks!
 
Dec 10, 2014
63
1
#5
You can try with the %@filewrite[…] category of functions.
Wellyes, as written in the op I'd like non-unicode output, and filewrite generates utf16 - so I'd need another xcode command to convert it.

Code:
rem or use setdos /x-6
set string=test1^<test2^>test3
set string > file.txt
Did you actually try this :-) ... doesn't work because the redirector is disabled by setdos, that's the whole point!

Thanks, I'll probably go for this. I already had a look before and the approach (same for html) seems a bit hack-ish as you need to disable utf output. But alas, due to the dodgy handling of utf8 by tcc I went the old-school latin way now anyway.
 
May 31, 2008
382
2
#8
Did you actually try this :-) ... doesn't work because the redirector is disabled by setdos, that's the whole point!
Of course I tried it. When I don't I usually add "(untested)" to the code in my replies. Did you notice that the first lin my code block is a comment and not a setdos command? The solution I gave you is equivalent to Charles' - there's only a difference in how > is escaped, ^ vs backquote.