0

How do I add unicode support in my batch file? I tried saving it as unicode and utf-8 but it still doesn't display foreign text properly. Example file:

@echo off
echo привет
pause
  • Are you unable to save your Unicode batch file, or are you unable to run it? – Simon MᶜKenzie Apr 15 '13 at 04:03
  • When I try to run it, it opens for a split second and closes automatically even though I added a pause at the end –  Apr 15 '13 at 04:12
  • If you launch it from a command prompt, it won't close, and you'll be able to see what went wrong. – Simon MᶜKenzie Apr 15 '13 at 04:19
  • _'l@' is not recognized as an internal or external command, operable program or batch file._ The l at the beginning is actually a bar and the error is referring to the first line in my batch file, `@echo off` –  Apr 15 '13 at 04:22
  • Please update your question with a sample of your code, including the line containing `l@`. – Simon MᶜKenzie Apr 15 '13 at 04:23
  • alright, added an example –  Apr 15 '13 at 04:26
  • [What encoding/code page is cmd.exe using](http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using) – Endoro Apr 15 '13 at 05:28
  • the problem you have may be related to [BOM](http://en.wikipedia.org/wiki/Byte_order_mark) being present in your file (which will trip cmd interpreter). Look for 'save utf-8 without BOM' or similar in your editor. – wmz Apr 15 '13 at 06:45

1 Answers1

1

From Wikipedia

The active OEM code page can be changed by the MS-DOS chcp command, but this will not display correctly unless you switch from the default raster font to Lucida Console. Raster fonts do not support non-system-wide changing of the code page.

If your batch file is in UTF-8, try executing chcp 65001 before your batch file (65001=CP_UTF8) and change font to Lucida Console.

Jacob Seleznev
  • 7,802
  • 3
  • 20
  • 33
  • I tried using that and saved a second batch file with foreign characters in it as Unicode but it still doesn't work –  Apr 15 '13 at 04:08
  • This is what I get when I add `chcp 65001` as the first line in my batch file: [link](http://i.imgur.com/4WmqKQc.png) –  Apr 21 '13 at 00:32