0

My operating system is Windows 10, and the system's default code page is GBK. The JDK version is 21, and the Gradle version is 8.5. I use chcp 1252 to change the console encoding. In order to check the System.out.charset of the gradle daemon process, I use System.out.print(System.out.charset()) in build.gradle,it is “utf-8”, while the VM property stdout.encoding of the Gradle daemon process is 1252. If I run a class file that outputs System.out.charset using the java command, the output of System.out.charset and stdout.encoding are both 1252. Why does the Gradle daemon output not equal stdout.encoding?

what i have tried:At first, I thought it was because stdout.encoding does not support the character set I specified. However, running a class file that outputs System.out.charset directly using the java command shows that the character set I specified is supported. I expected that System.out.charset should equal stdout.encoding. Please forgive me for my poor English.

7
  • 2
    How are you setting the encoding? And why do you expect the Gradle encoding to match thr encoding of the Java application?
    – dan1st
    Commented Jul 6 at 18:50
  • 2
    What is the real problem, indeed, what is the GOAL?
    – g00se
    Commented Jul 6 at 20:10
  • @dan1st There are no other encoding settings except for using chcp to set the console to 1252. By default, system.out.charset should be equal to jvm property stdout.encoding. But why are they not equal in the gradle daemon process? Did gradle daemon modify System.out?
    – ok im
    Commented Jul 7 at 0:22
  • Does setting the stdout.encoding system property of the daemon help?
    – Slaw
    Commented Jul 7 at 2:11
  • 1
    Perhaps it would be good to provide a minimal reproducible example.
    – Slaw
    Commented Jul 7 at 6:07

1 Answer 1

0

Eventually found in gradle's source code, gradle modifies the output stream using System.setOut, so System.props "stdout.encoding" does not match System.out.charset(). In addition, gradle also modifies the "stdout.encoding" in Sytem.props, resulting in an inconsistency with the console encoding.

Not the answer you're looking for? Browse other questions tagged or ask your own question.