twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
1.18k stars 71 forks source link

Can't display Chinese characters #215

Open Qinggao1729 opened 1 year ago

Qinggao1729 commented 1 year ago

My system language is Chinese, so if I run java file in windows terminal, it will display Chinese. But when I run it in obsidian, the Chinese characters can't be displayed normally. image image

I know there's a similar issue here #126 about printing Chinese characters, but my case is about displaying error messages. Is there any way to solve the issue?

Edit: I'm running Git Bash on windows11. Also, my system language is Chinese.

chlohal commented 1 year ago

Interesting, thank you! :)

Could you try using the -DFile.Encoding=UTF-8 argument in the plugin settings?

image

Qinggao1729 commented 1 year ago

No, it doesn't work. image image

twibiral commented 1 year ago

I think the issue is similar to this: https://stackoverflow.com/questions/28567208/how-can-i-change-the-standard-out-to-utf-8-in-java

The output stream is differently encoded than the text in Obsidian. Maybe we need to solve this globally by changing the encoding of every character before adding it to the output block in Obsidian.

Qinggao1729 commented 1 year ago

I think the issue is similar to this: https://stackoverflow.com/questions/28567208/how-can-i-change-the-standard-out-to-utf-8-in-java

The output stream is differently encoded than the text in Obsidian. Maybe we need to solve this globally by changing the encoding of every character before adding it to the output block in Obsidian.

Sorry, I don't understand. I want to change it to display the error message. Can it work too?

chlohal commented 1 year ago

I see: it's not just the java std streams, but the javac ones too.

Would you mind entering the following command & sending a screenshot of the output? This will help get a grasp on the encoding that your system uses.

javac HelloWorld.java 2> /dev/stdout | xxd
Qinggao1729 commented 1 year ago

I see: it's not just the java std streams, but the javac ones too.

Would you mind entering the following command & sending a screenshot of the output? This will help get a grasp on the encoding that your system uses.

javac HelloWorld.java 2> /dev/stdout | xxd

image It prints nothing.

(I'm running Git Bash on windows11. Also, my system language is Chinese.)

Qinggao1729 commented 1 year ago

Not sure if this is relevant: the error messages displayed on my IntelliJ was also Chinese originally, but I followed the instruction here to change it to English: https://stackoverflow.com/a/47529952/21070222

qiaogaojian commented 1 year ago

try this: https://stackoverflow.com/questions/57131654/using-utf-8-encoding-chcp-65001-in-command-prompt-windows-powershell-window