简体   繁体   English

IntelliJ使用错误的编码

[英]IntelliJ uses wrong encoding

I am using intelliJ 2017.3 CE, I have a strange behaviour which i cannot resolve although I tried everything I found to that topic. 我正在使用intelliJ 2017.3 CE,尽管尝试了该主题的所有内容,但是我无法解决这种奇怪的行为。

For simplicity I extracted the root cause of my problem, IntelliJ does not use the desired encoding in my case UTF-8. 为简单起见,我提取了问题的根本原因,在我的情况下,IntelliJ没有使用所需的编码UTF-8。 Here is my simple class: 这是我的简单课程:

public static void main(String[] args) {
    System.out.println("äüö");
}

running this class leads to the following output: 运行此类将导致以下输出:

13:03:47: Executing task 'StringTest2.main()'...
:core:compileJava UP-TO-DATE
:core:processResources UP-TO-DATE
:core:classes UP-TO-DATE
:core:compileTestJava
:core:processTestResources UP-TO-DATE
:core:testClasses
:core:StringTest2.main()
äüö


BUILD SUCCESSFUL in 2s
5 actionable tasks: 2 executed, 3 up-to-date
13:03:49: Task execution finished 'StringTest2.main()'.

Here you can see the encoding of the file 在这里您可以看到文件的编码

在此处输入图片说明

here are the settings of my intellij installation 这是我的IntelliJ安装的设置 在此处输入图片说明

What I tried: 我试过的

  • added to my gradle.properties: systemProp.file.encoding=utf-8 添加到我的gradle.properties中:systemProp.file.encoding = utf-8
  • created a run configuration for that class where i defined jvm settings: -Dfile.encoding=utf-8 为该类创建了运行配置,其中我定义了jvm设置:-Dfile.encoding = utf-8
  • executed a testcase where this problem originally occured from command line (gradle) but the error also occured 执行了一个测试案例,该问题最初是从命令行(gradle)发生的,但也发生了错误
  • Tested the class on a different pc (mac) with intellij and there the log out was as expected. 使用intellij在另一台PC(mac)上测试了该类,并且注销符合预期。

I dont know what else I can try. 我不知道我还能尝试什么。

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

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