Java,UTF-8和Windows控制台 [英] Java, UTF-8, and Windows console

查看:363
本文介绍了Java,UTF-8和Windows控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们尝试在Windows上使用Java和UTF-8。应用程序在控制台上写日志,我们希望使用UTF-8作为日志,因为我们的应用程序具有国际化日志。

We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs.

可以配置JVM它生成UTF-8,使用 -Dfile.encoding = UTF-8 作为JVM的参数。它工作正常,但在Windows控制台的输出是乱码。

It is possible to configure the JVM so it generates UTF-8, using -Dfile.encoding=UTF-8 as arguments to the JVM. It works fine, but the output on a Windows console is garbled.

然后,我们可以将控制台的代码页设置为65001( chcp 65001 ),但在这种情况下, .bat 文件不起作用。这意味着,当我们尝试通过我们的脚本(名为start.bat)启动我们的应用程序时,绝对没有任何反应。命令简单返回:

Then, we can set the code page of the console to 65001 (chcp 65001), but in this case, the .bat files do not work. This means that when we try to launch our application through our script (named start.bat), absolutely nothing happens. The command simple returns:

C:\Application> chcp 65001
Activated code page: 65001
C:\Application> start.bat

C:\Application>

但没有 chcp 65001

推荐答案

尝试 chcp 65001&& start.bat

这篇关于Java,UTF-8和Windows控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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