Vscode-code-runner: 测试中文输出的时候是乱码!

Created on 18 Nov 2017  ·  7Comments  ·  Source: formulahendry/vscode-code-runner

tim 20171118143456
测试中文的乱码问题如何解决!
我已经设置了"code-runner.runInTerminal": true,还是乱码。

同时我还有一个问题就是之前我运行测试代码直接鼠标右键选择run code来运行,但老是会额外生成一个tempCodeRunnerFile.java ,这样导致我的类名和文件名不统一发送错误,但是我ctrl+alt+j 在选择java运行就可以了,我想直接右键 run code ,不额外再生产个tempCodeRunnerFile.java 的文件,而是直接运行当前类要如何设置。
tim 20171118143808

谢谢...

external

Most helpful comment

@formulahendry 关于UTF-8编码的.java文件乱码的问题,可以通过如下方式解决:

temp

在"code-runner.executorMap"的java命令里,
由原先的
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt"

在编译时,添加上用UTF-8编译的配置,变成
"java": "cd $dir && javac -encoding UTF-8 $fileName && java $fileNameWithoutExt"

javac后面多了-encoding UTF-8

即可实现无乱码的效果。

All 7 comments

For messy code, what encoding are you using?
image

For tempCodeRunnerFile.java, it is because you have selection on the code. You could use below setting to avoid that:

{
    "code-runner.ignoreSelection": true
}

我使用的是UTF—8的编码方式,但是我这边试了下还是乱码:

第二个运行的问题已经完美解决了!

------------------ 原始邮件 ------------------
发件人: "Jun Han";notifications@github.com;
发送时间: 2017年11月20日(星期一) 下午2:46
收件人: "formulahendry/vscode-code-runner"vscode-code-runner@noreply.github.com;
抄送: "E╮先生 🎈 "1470976@qq.com; "Author"author@noreply.github.com;
主题: Re: [formulahendry/vscode-code-runner] 测试中文输出的时候是乱码! (#209)

For messy code, what encoding are you using?

For tempCodeRunnerFile.java, it is because you have selection on the code. You could use below setting to avoid that:
{ "code-runner.ignoreSelection": true }


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

For messy code, could you try to run it in the terminal of your OS?

果然是系统终端的问题,我按照百度设置了AVA_TOOL_OPTIONS编码方式,但是依旧还是存在乱码问题,请问您可以告诉我有什么解决办法吗?

------------------ 原始邮件 ------------------
发件人: "Jun Han";notifications@github.com;
发送时间: 2017年11月20日(星期一) 下午3:30
收件人: "formulahendry/vscode-code-runner"vscode-code-runner@noreply.github.com;
抄送: "E╮先生 🎈 "1470976@qq.com; "Author"author@noreply.github.com;
主题: Re: [formulahendry/vscode-code-runner] 测试中文输出的时候是乱码! (#209)

For messy code, could you try to run it in the terminal of your OS?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Sorry, no idea about that. Closing it as external issue.

@formulahendry 关于UTF-8编码的.java文件乱码的问题,可以通过如下方式解决:

temp

在"code-runner.executorMap"的java命令里,
由原先的
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt"

在编译时,添加上用UTF-8编译的配置,变成
"java": "cd $dir && javac -encoding UTF-8 $fileName && java $fileNameWithoutExt"

javac后面多了-encoding UTF-8

即可实现无乱码的效果。

@hanshou101 thanks for your solution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhavinkamani picture bhavinkamani  ·  4Comments

w3adventures picture w3adventures  ·  3Comments

spacesuitdiver picture spacesuitdiver  ·  3Comments

seiferthan picture seiferthan  ·  4Comments

nmchgx picture nmchgx  ·  3Comments