unicode - Batch script is not executed if chcp was called -


I am trying to delete some files with batch scripts with Unicode characters (this is a requirement). So I run and execute CMD:

  & gt; ChcP 65001  

Setting codepatting in UTF-8 effectively and works:

  D: \ Temp 1 1 gt; There is no label in the Drive D in the dial, the volume serial number 8C 33-61 of the BF directory is: \ temp \ 1 02.02.2010 09:31 & lt; DIR & gt; . 02.02.2010 09:31 & lt; DIR & gt; .. 02.02.2010 09:32 508 1.txt 02.02.2010 09:28 Remove 12.bat 02.02.2010 09:20 95 delete cmd 02.02.2010 09:13 & lt; DIR & gt; Run 02.02.2010 09:13 & lt; DIR & gt; Гуцул Каліпсо 3 files 615 bytes 4 Dir (s) 11 576 438 784 bytes free D: \ Temp 1 1> RMDIR RUN D: \ HEAP 1 1> Drive D does not have a label of dial volume Volume serial number 8C33-61 BF directory belongs to: \ temp \ 1 02.02.2010 09:56 & lt; DIR & gt; . 02.02.2010 09:56 & lt; DIR & gt; .. 02.02.2010 09:32 508 1.txt 02.02.2010 09:28 Remove 12.bat 02.02.2010 09:20 95 delete cmd 02.02.2010 09:13 & lt; DIR & gt; Guzulle Callips 3 files 615 bytes 3 Dir (s) 11 576 438 784 bytes free  

Then I put the same rmdir command in the batch script. This UTF-8 encoding But when I do not go anywhere, not really anything: in this case the batch does not even work from the script. Even in the OEM encoding it does not help to save the script.

It seems that when I change the codef to UTF-8 in the console, the scripts just stop working. Does anyone know how to fix it?

If you want Unicode supported in the batch file, then CAPP will close the batch file from one line. I give the suggestion that every batch file is inserting the CHCP on the line, which requires Unicode

  chcp 65001 & gt; Neul & amp; & Lt; The actual command here & gt; Example: In my case, I wanted to take a good paragraph of my log files while debugging, but material was also messing up for Latin-1 characters. So here is my batch file which wraps the actual tail implementation from the Windows Resource Kit.  
  @C: \ WINDOWS \ system32 \ chcp.com 65001 & gt; Tap & amp; Amp; Tail.exe -f% 1  

Additionally, for the output of the console, you have to set a true font type, i.e. Lucidia Console

And apparently, in a file, the output needs to run the command line as Unicode, so you will bring your batch script down as follows:

  Cmd / u / c & lt; Batch file command here & gt;  

Disclaimer: tested on Windows XP SP3 with Windows Resource Kit.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -