如何通过命令行将象形文字作为参数传递给main方法 [英] How to pass hieroglyphs as an argument to the main method from command line

查看:81
本文介绍了如何通过命令行将象形文字作为参数传递给main方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的问题,但我找不到答案。有人知道如何通过命令行将象形文字作为参数传递给main方法吗?
下面有一些伪代码可以帮助测试建议的解决方案:

I met some interesting question on which I was not able to find an answer. Does anybody know how to pass hieroglyphs as an argument to the main method from command line? Below there is some pseudo code which will help to test suggested solution:

public class Test {
    public static void main(String args[]) {
        if ("香港政府".equals(args[0])) {
            System.out.println("Match");
        }
    }
}

所以问题是怎么打电话 Test.class 带有参数,以便应用程序将 Match 打印到控制台?在传递给 if 语句之前,可以先转换 args [0]

So question is how to call Test.class with an argument so the application prints Match to the console? args[0] can be transformed before passing to the if statement.

预先感谢。

推荐答案

经过一些进一步的研究,我终于能弄清楚了。因此,对问题发表评论的人都非常接近答案。我尝试找到的
编码是 936 。但这并不意味着如果您的操作系统语言环境不是中文,则可以运行 chcp 936 。一旦您尝试在除中文以外的其他语言环境中运行它,

After some additional research I was able kinda figured it out. So guys who commented on question were very near to the answer. Encoding which I tried to find was 936. But it doesn't mean that you will be able to run chcp 936 if you OS locale is other than chinese. Once you will try to run it on other locale than chinese:

chcp 936

您将收到以下错误:

无效代码页

要使其正常工作,您必须更改区域。将需要执行以下步骤:

For making it working you have to change region. FOllowing steps will be needed:


  1. 开始-COntrol面板

  2. 选择区域和语言

  3. 选择管理,然后单击更改系统区域设置...

  4. 选择中文(简体中文)并重新启动笔记本电脑

  1. Start - COntrol panel
  2. Select "Region and Language"
  3. Select "Administrative" and click "Change system locale..."
  4. Select "Chinese (Simplified, PRC)" and reboot laptop

重新启动后,当您运行 chcp 时,您将看到以下输出 Active代码页:936 。现在,您可以使用象形文字执行命令行了。

After restart when you will run chcp you will see following output Active code page: 936. Now you are ready to execute command line with hieroglyphs.

这篇关于如何通过命令行将象形文字作为参数传递给main方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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