简体   繁体   English

如何执行带有汉字的批处理文件

[英]How to execute a batch file with chinese characters

Our automation test framework creates batch files as part of starting an application (.exe). 我们的自动化测试框架会在启动应用程序(.exe)的过程中创建批处理文件。 In my case this application takes username and passwords as arguments. 就我而言,该应用程序将用户名和密码作为参数。 As part of one of the test cases, username is a chinese name. 作为测试用例之一,用户名是中文名称。 Test framework is creating batch file with correct chinese username but the application's UI is taking some junk values(with question marks and some other symbols) in the corresponding username field. 测试框架正在使用正确的中文用户名创建批处理文件,但是应用程序的UI在相应的用户名字段中采用了一些垃圾值(带有问号和其他符号)。 So, authentication is failing. 因此,身份验证失败。

I have searched and tried to use chcp codepage command in the generated batch file, updated batch file with different values of code page numbers (1250,1252,1253,65001,..). 我已经搜索并尝试在生成的批处理文件中使用chcp codepage命令,并使用不同的代码页码值(1250,1252,1253,65001,..)更新了批处理文件。 But nothing worked. 但是没有任何效果。 But When I use code page number 1250, one of the chinese character(first character among three) is received by application correctly but junk values for other characters. 但是,当我使用代码页号1250时,应用程序正确接收了一个汉字(三个字符中的第一个字符),而其他字符则为垃圾值。

Ex. 防爆。 content of batch file: xxx.exe -user "abc" -password "xyz" 批处理文件的内容:xxx.exe-用户“ abc”-密码“ xyz”

How can I solve this problem, Not able to find solutions by searching internet. 如何解决此问题,无法通过搜索Internet找到解决方案。

解决方案是针对utf8的CHCP 65001或您使用的任何页面-decas

I had a similar problem with the "€" sign. 我在“€”符号上也遇到了类似的问题。 The onyl way I've found was to change the font of the cmd console to one that recognized the the symbol. 我发现的onyl方法是将cmd控制台的字体更改为可识别该符号的字体。 However, this only helped while calling the bat file from an already opened console with the changed font. 但是,这仅在从已经打开的控制台以更改的字体调用bat文件时有用。 Doubleclicking on the bat file didn't work because then the font was reset to system default. 双击bat文件不起作用,因为随后字体被重置为系统默认值。 Finally I've fixed it by changing the default cdm font in the registry but I'm not sure whether this helps you. 最后,我通过更改注册表中的默认cdm字体修复了该问题,但不确定是否有帮助。 While I've selected a font that had any other latin char and also some special symbols like €, ö, ß etc, I'm not sure whether there is a font that contains chinese AND latin chars. 虽然我选择了具有其他拉丁字符的字体以及一些特殊的符号,例如€,ö,ß等,但是我不确定是否存在包含中文和拉丁字符的字体。

您需要在文本编辑器中选择“ ANSI”作为编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM