使用“En Dash”在输入文件中添加到批处理文件 [英] Using "En Dash" in an input file to a batch file

查看:396
本文介绍了使用“En Dash”在输入文件中添加到批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最不幸的是,我收到了几个TFS团队项目,在其中加入了一个。



如果你不熟悉en dash,打开MS Word并键入alt + 8211。



你会看到一个更大的看法。 (像这样,如果它呈现给你: - )。如果你打开记事本,你会看到一个?如果你在大多数Unicode编辑器中尝试它,你会看到!



但我需要它是一个破折号。因为我需要对我的所有项目运行一个批处理文件。



我创建了一个保存项目名称的文件,并将它们提供给我的批处理文件。

p>

但是当它运行时,它代替 - 。



我可以做什么来保持我的破折号?



注意:
我有两个批处理文件。第一个用文件中的参数运行第二个。



我的第一个可以是在这里看到。第二个可以在此处查看。输入文件的示例可以是在此处查看

解决方案

链接字符是Unicode码点U + 2013。在Windows代码页1252中,它是字符号150.û字符是代码页437中的字符号150.因此,看起来一个进程正在代码页1252中写入文件,而另一个进程正在使用代码页437读取它。 p>

理想情况下,除了Unicode以外的所有代码页都应该与世界大战,小痘痘和20世纪的其他文物一起抛出。不幸的是,Windows控制台让这很困难。



由于代码页437是大多数Windows安装的默认控制台代码页,我怀疑是默认设置造成这些问题。 (文件名由操作系统以Unicode格式存储,因此至少部分是正确的。)由于代码页437不包含字符串,因此使用该代码页的任何系统都必须使用回退机制来渲染



通过将控制台代码页更改为支持en dash字符的文件(例如1252),此问题可能会被更正。



您可以使用以下命令更改此代码页。

  chcp 1252 

此命令应该放在批处理文件的开头。



这是一个可怕的黑客,这将是必要的,直到你可以转换你的系统到现代的支持Unicode从上到下。



您可能还想在Powershell中尝试,因为PS支持Unicode。


Most tragically, I got several TFS team projects with an en dash in them.

If you are not familiar with en dash, open up MS Word and type in alt+8211.

You will see a larger looking dash. (Like this if it renders for you: –). If you open notepad you will see a ? and if you try it in most Unicode editors you will see ‼.

But I need it to be a dash. Because I need to run a batch file against all my projects. The paths to the projects now has this en dash in it.

I make a file that holds the names of the projects and I feed them to my batch file.

But when it runs it puts û in place of the –.

What can I do to keep my dash?

NOTE: I have two batch files. The First runs the second with params from a file.

My First one can be seen here. The second can be seen here. An example of the input file can be seen here.

解决方案

The en dash character is Unicode code point U+2013. In Windows code page 1252 it is character number 150. The û charcter is character number 150 in code page 437. So it looks like one process is writing a file in code page 1252, while another is reading it using code page 437.

Ideally, all code pages other than Unicode should be thrown out along with World Wars, small pox, and other relics of the 20th century. Unfortunately, the Windows console makes this rather difficult.

Since code page 437 is the default console code page for most Windows installations, I suspect that it is this default setting that is causing these problems. (File names are stored by the OS in Unicode, so that part, at least, is correct.) Since code page 437 does not include the en dash character, any system using that code page will have to resort to a fallback mechanism to render the file names, such as a question mark.

By changing the console code page to something that does support the en dash character, such as 1252, this problem may be corrected.

You can change this code page with the following command.

chcp 1252

This command should probably be placed at the beginning of your batch file.

This is a terrible hack that will be necessary until you can convert your system to something modern that supports Unicode from top to bottom.

You may also want to try it in Powershell, since PS does support Unicode.

这篇关于使用“En Dash”在输入文件中添加到批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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