Page 1 of 1

Can't run bat files when using anything other than 'ta' with 'writefile'

Posted: 15 Aug 2021 08:28
by 1024mb
I'm creating a bat file using 'writefile' with success, the problem comes when I need to write the file as UNICODE, if I use tu or r, the file is created but I can't execute it. My system is 1252. I have to use UNICODE because some of the text in the batch file is Russian and using ANSI outputs ??????? instead of the real text, this is a sample of what XYplorer should write:

Code: Select all

cd /D "O:\Gunther & The Sunshine Girls СинглоГрафия"
Using 'ta' results in ????? instead of the Russian text, using tu results in a correct file (at least apparently) but can't run it, same if I use 'r'. What I'm I missing here? Can someone test this? Maybe my machine is the problem.

I have tried running the file by double clicking it and also by opening a cmd window and executing the bat from there (so I can see the output but it shows nothing at all, like I did nothing).

PS: Also, why using utf8 or even utf8bom gives the same results as using ta? UTF-8 should be OK and the Russian text be written correctly, isn't it?

EDIT: Ok, with the sample that I shared above my cmd window now says:
"■c" not recognized as an internal or external command, program, or executable batch file.
Whereas before, minutes ago, it didn't output anything.

Re: Can't run bat files when using anything other than 'ta' with 'writefile'

Posted: 15 Aug 2021 08:35
by highend
use a chcp 65001
at the beginning of the bat content
and write it as utf8

Re: Can't run bat files when using anything other than 'ta' with 'writefile'

Posted: 15 Aug 2021 08:44
by 1024mb
highend wrote: ↑15 Aug 2021 08:35 use a chchp 65001
at the beginning of the bat content
and write it as utf8
Thank you, that worked.
I didn't know how I managed to fix it before (at least it worked once) but then it stopped working with accented characters (and the 'ñ') so I had to put it like it was before but with your solution it works with both. :appl: