具有非ASCII字符的批处理文件 [英] Batch file with non-ASCII characters

查看:181
本文介绍了具有非ASCII字符的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要链接到批处理脚本中包含字符æ"的文件夹.

I need to link to a folder that contains the character "æ" in a batch script.

虽然我运行脚本时遇到麻烦.命令提示符错误读取了非ASCII字符.我尝试将文件另存为ANSI和Unicode.我正在运行Windows 7.

I run into trouble when I run the script though. The command prompt misreads the non-ASCII characters. I've tried saving the file as both ANSI and Unicode. I'm running Windows 7.

这是一个最小的例子:

echo øl

推荐答案

默认情况下,控制台窗口中是否使用 ANSI Unicode .默认情况下,Windows使用 OEM 代码页作为控制台.

There is whether ANSI nor Unicode used by default in console windows. By default Windows uses for console a OEM code page.

使用哪个 OEM 代码页取决于Windows区域和语言设置.对于美国和加拿大,默认的OEM代码页为 437 ,对于西欧国家,默认的代码页为 437 850 .

Which OEM code page is used depends on Windows region and language settings. For US and Canada the default OEM code page is 437, for Western European countries the default code page is 850.

对于美国,加拿大和西欧国家/地区,GUI窗口中的非Unicode代码页为 Windows-1252 .

For US, Canada and Western European countries the non Unicode code page in GUI windows is Windows-1252.

字符æ具有十进制代码值 230 (十六进制E6)在Windows-1252代码页以及Unicode表中.但是在OEM代码页437和850中,此字符的十进制代码值为 145 (十六进制91).

The character æ has decimal code value 230 (hex. E6) in code page Windows-1252 as well as in Unicode table. But in OEM code page 437 and 850 the decimal code value of this character is 145 (hex. 91).

因此,您需要使用 SomethingDark 建议的方法将此字符插入批处理文件中,或编辑批处理文件直接在文本编辑器中使用相应的OEM代码页.

So you need to insert this character into the batch file either with method suggested by SomethingDark or you edit the batch file in text editor directly using the appropriate OEM code page.

我正在使用UltraEdit编辑文本文件.我已将UltraEdit配置为自动使用系统定义的OEM代码页(在我的情况下为代码页850)针对扩展名为BAT和CMD的文件,对于所有其他非Unicode文本文件,将GUI窗口的系统代码页(代码页1252)使用以我为例).在将例如在浏览器中复制的文本粘贴到批处理文件中时,UltraEdit还会进行从Unicode或Windows-1252到OEM代码页850的必要转换.而且,在将批处理文件中的选定文本复制到剪贴板中时,UltraEdit还将OEM编码的字符也从850转换为1252,并转换为Unicode.

I'm using UltraEdit for editing text files. I have configured UltraEdit for automatically using OEM code page as defined by the system (code page 850 in my case) for files with extension BAT and CMD and use for all other non Unicode text files the system code page for GUI windows (code page 1252 in my case). UltraEdit makes also the necessary conversion from Unicode or Windows-1252 to OEM code page 850 on pasting a text copied for example in browser into the batch file. And UltraEdit converts the OEM encoded characters also from 850 to 1252 and Unicode on copying a selected text in batch file to clipboard.

要在控制台窗口中找到您的计算机上使用了哪个OEM代码页,请打开命令提示符窗口并运行命令chcpmode con.

To find out which OEM code page is used on your machine in console windows, open a command prompt window and run either command chcp or mode con.

这篇关于具有非ASCII字符的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆