I created a batch file that contains characters in Hebrew.
ECHO אאאאא
The result is אאא
on running the batch file.
How can I fix it?
It looks like you have encoded your batch file with UTF-8 saved without byte order mark (BOM) for Hebrew Letter Aleph with Unicode code value 05D0.
The batch code below copied into a UTF-8 encoded file without BOM changes the code page to UTF-8 (65001) before the characters are written into the console window.
@echo off
chcp 65001 >nul
ECHO אאאא
Instead of using multi-byte encoding UTF-8, it would be also possible to use single-byte encoding with code page 862 which contains this letter mapped to code value 80 (hexadecimal, 128 decimal).
@echo off
chcp 862 >nul
ECHO אאאא
Code page 862 is the OEM code page for Hebrew.
In console windows usually OEM code pages are used. If you open a command prompt window and execute in this window chcp
you can see which code page is by default set on your machine.
But setting the right code page in batch file according to encoding used for the batch file does not automatically mean to get the Hebrew letters now displayed correct in console window on execution of the batch file.
The font used for the console window must support code page 862 respectively the Hebrew letters from Unicode table, too.
As I saw the Hebrew characters displayed wrong in command prompt window with default font setting Raster Fonts on my English Windows 7 x64 machine using by default code page 850 in console windows, I clicked on icon on left side of title bar of command prompt window, clicked in opened menu on Properties and selected Consolas on tab Font. The Hebrew letters were displayed now different than with Raster Fonts, but still not right. So Consolas also does not support Hebrew letters on my machine. Next I tried font Lucida Console, but again the Hebrew letters were not displayed right. In other words non of the 3 fonts available on my machine for console windows can be used to display the Hebrew letters in a console window with the right glyphs.
Read this brief overview of Unicode on a power tip page for text editor UltraEdit if you don't know anything about text encoding.
Command prompt environment is not really designed for Unicode. Select in Windows Control Panel - Region and Language the tab Administrative. There you can set system locale for non-Unicode programs. And there is also a link to a help page explaining what this settings is for - setting default font and code page for single byte encoded text in Windows GUI (Windows-1255) and console windows (OEM 862) with Hebrew (Israel) selected.
来源:https://stackoverflow.com/questions/30478940/how-to-fix-a-batch-file-with-an-hebrew-font