Advice for printing unicode symbols on Windows


(Adarsh Ramamurthy) #1

I am in the process of developing a plugin that makes use of the Gradle Logger to print messages to the console. These messages sometimes contain Unicode symbols such as :heavy_check_mark: (U+2714) and ✘ (U+2718).

On Linux and Mac terminals, I have no problems at all in displaying these symbols. However, on Windows due to a combination of the code page and default character set, I either see ? or some garbled up characters.

I was wondering if anyone over here has faced similar issues wanted to seek some help.

I am looking to make my solution work equally well on Windows PowerShell, Command Prompt and any other tools such as Cygwin or Git Bash.

(Carlo Luib-Finetti) #2

You have to set an appropriate code page, i.e. UTF-8 with command: “chcp 65001” and use an appropriate font liek Consolas or Lucida Console.

(Adarsh Ramamurthy) #3

Thanks @carlo_lf. This is what I am doing currently.

However I have seen that projects such as mochajs work even with code page 850 (the default). I did however see a PR that changes mochajs to use different characters (such as square root - √ instead of heavy checkmark) on Windows.

I was hoping that the users of my plugin wouldn’t have to make changes to their system to display Unicode symbols but it’s probably a limitation of Java.