且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用希伯来语字体修复批处理文件

更新时间:2023-02-26 12:35:14

看起来您已经使用 UTF-8 保存,不需要字节顺序标记( BOM)希伯来语字母Aleph ,Unicode代码值为05D0。 p>

下面的批处理代码复制到没有BOM的UTF-8编码文件中,在将字符写入控制台窗口之前,将代码页更改为UTF-8(65001)。 p>

  @echo off 
chcp 65001> nul
ECHOאאאא

而不是使用多字节编码UTF-8,我们也可以包含此字母的代码页862 的单字节编码,其中映射到代码值80(十六进制, 128小数)

  @echo off 
chcp 862> nul
ECHOאאאא

代码页862是希伯来语的OEM代码页。



在控制台窗口中通常使用OEM代码页。如果您打开命令提示符窗口并在此窗口 chcp 中执行,您可以看到默认情况下设置在您的计算机上的代码页。



但是,根据批处理文件使用的编码,在批处理文件中设置正确的代码页并不意味着在执行批处理文件时,在控制台窗口中显示希伯来字母正确显示。



用于控制台窗口的字体必须分别支持代码页862的Unicode表格中的希伯来字母。



当我看到希伯来字符在我的英文Windows 7 x64机器上使用默认字体设置光栅字体在命令提示符窗口中显示错误使用默认情况代码页850 中,我点击了命令提示符窗口标题栏左侧的图标,点击了属性的打开菜单,选择了 Consolas 选项卡字体即可。希伯来字母现在显示与光栅字体不同,但仍然不正确。所以 Consolas 也不支持我的机器上的希伯来字母。接下来,我尝试了字体 Lucida控制台,但是希伯来字母再次显示不正确。换句话说,我的机器上的控制台窗口中没有3种字体可用于在控制台窗口中使用正确的字形显示希伯来字母。



阅读这个简要概述Unicode 在文本编辑器的电源页面UltraEdit如果你不知道什么文字编码。



命令提示环境并不是真正为Unicode设计的。在 Windows控制面板 - 区域和语言中选择管理。在那里,您可以为非Unicode程序设置系统区域设置。还有一个指向帮助页面的链接,解释了这种设置 - 在选择了希伯来语(以色列)的Windows GUI(Windows-1255)和控制台窗口(OEM 862)中设置单字节编码文本的默认字体和代码页。


I created a batch file that contains characters in hebrew

ECHO אאאאא

when running the result is אאא

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.