Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicode not displaying properly in Gradle console

this is my very first question/post on here, because I am officially stuck. I am having difficulty displaying Unicode characters in Java/Gradle console. My project name is 'Blackjack'.

An example snippet of code:

    System.out.println("♣");
    System.out.println("\u2663");

This prints out:

    ?
    ?

If I go to File | Settings | Build, Execution, Deployment | Build Tools | Gradle; and change 'Build and run using' from Gradle (Default) to IntelliJ IDEA, then the console prints out the characters correctly:

    ♣
    ♣

However, I'd really like to use the Gradle console as this is what I am currently learning.

The things I have checked so far:

  • File | Settings | Editor | File Encodings; 'Global Encoding', 'Project Encoding', and encoding of my Card.java file are all set to UTF-8. I've tried changing 'Default encoding for properties files' from ISO-8859-1 to UTF-8, but it made no difference.

  • In the bottom right corner of IntelliJ IDEA, it's already set to UTF-8.

  • In gradle.xml and encodings.xml, UTF-8 is already specified.

  • File | Settings | Tools | Terminal; Shell path is set to C:\Windows\system32\cmd.exe

The things I have changed/tried so far:

  • I have edited the idea64.exe.vmoptions file to include:

      -Dconsole.encoding=UTF-8
      -Dfile.encoding=UTF-8
    
  • I have created a ./gradle/gradle.properties file and added:

      org.gradle.jvmargs=-Dfile.encoding=UTF-8
      systemProp.file.encoding=utf-8
    

I have added this line of code before the two println:

    System.setProperty("file.encoding", "UTF-8");

If anyone has any other suggestions, please let me know as I've ran out of options.

like image 976
adanglingpointer Avatar asked Oct 21 '25 11:10

adanglingpointer


1 Answers

It's an issue with the terminal/console program that is being used, and not really anything to do with Gradle.

Probably the easiest solution is to use a terminal that uses UTF-8 as standard. That looks to be the case with Powershell, which looks to be bundled with Windows. So you can open that and run your Gradle commands from there and it should give the results you want.

If that works you can set it up as the default terminal in IntelliJ IDEA.

like image 153
Simon Jacobs Avatar answered Oct 23 '25 01:10

Simon Jacobs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!