简体   繁体   中英

Java, not printing Chinese Character in Visual Studios Code, but works in Python

When I do System.out.println('说'); It just prints "?"

In the bottom right corner it says UTF-8 (so that is good). I have no idea what I am doing wrong, any help much appreciated. PS: When I make a python file and print it, it prints it properly. But not in java:(

I tried doing System.setProperty("file.encoding", "UTF-8"); but same result sadly. I tried running code in repl.it, and it works. But not in visual studios.

Note that windows Locale is set to support UTF-8. And I am using Consolas Font, which should support UTF-8. I also tried uninstalling VS and installing it again - it didn't fix anything.

I am also using terminal for all output.

What is your machine language? Change the system language to Chinese , and modify the system locale to Chinese (you may need to restart the computer), then restart vscode and print out Chinese characters.

在此处输入图像描述

Another simple and effective way is to use the Code Runner extension. Install the extension and execute the script with Run Code , the OUTPUT panel will display the result.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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