Skip to content

chinese character don't display appropriate #260

Closed

Description

@xpf7622

// Hello world java file is utf-8
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World! 汉字!");
}
}

output as follows:

Hello World! 姹夊瓧锛�

but java file have the default code utf-8. and Debugger for java default also utf8, why the output is abnormal character!

Operating system : simplified Chinese win10 ; version. : 1709(16299 .334)

launch.json:
"configurations": [
{
"type": "java",
"name": "Java Debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopOnEntry": false,
"mainClass": "HelloWorld",
"encoding": "UTF-8",
"args": ""
},
……

Activity

  1. akaroml commented on Mar 25, 2018

    @akaroml
    Member

    Jinbo Wang (@testforstephen) please take a look.

  2. andxu commented on Mar 26, 2018

    @andxu
    Contributor

    xpf7622 could you please upload your HelloWorld.class to this issue?

  3. xpf7622 commented on Mar 26, 2018

    @xpf7622
    Author

    Andy Xu(devdiv) (@andxu) Debug doesn't produce HelloWorld.class file。

  4. xpf7622 commented on Mar 26, 2018

    @xpf7622
    Author

    this is my java file. debug process doesn't produce HelloWorld.class file.
    HelloWorld.zip

  5. HaiUIT-zz commented on Mar 30, 2018

    @HaiUIT-zz

    I have the same problem with you, after I set my java file encode to UTF-8 with BOM it work and print the right text. But it is not a solution, because javac doesn't work with UTF-8 with BOM. If i run javac or use other build tool like gradle, maven to build my code, it will throw this error :

    > javac -encoding UTF8 Test.java
    Test.java:1: error: illegal character: '\ufeff'
    ?class Test {
    ^
    It seem like there is some problems in compile phase, here is my source code, the class file build with javac and the class file build with java debug extension. I have check both class files with hex editor and confirmed that they have different length and content.

    App.zip

  6. yiailake commented on Apr 4, 2018

    @yiailake

    me too.I found the class file in
    /Users/xxx/Library/Application Support/Code/User/workspaceStorage/b72b50a9aa05f002d6a626eedc811d53/redhat.java/jdt_ws/jdt.ls-java-project/bin
    Then I use command java Hello, the output can't display normal chinese character!

  7. testforstephen commented on Apr 11, 2018

    @testforstephen
    Contributor

    The underlying compiler (jdt complier) used by java debug extension looks like using the OS default encoding to parse the source file, when source file encoding is not same as the system encoding, the generated .class file will contain messy string literal. Need find a way to pass the correct source file encoding to the jdt compiler.

  8. testforstephen commented on Apr 11, 2018

    @testforstephen
    Contributor

    The encoding configuration item in launch.json mainly affects the character data parsed from the external input, such as console input or network input. It doesn't affect the print of the hard coded string constants in source file.

  9. testforstephen commented on Apr 12, 2018

    @testforstephen
    Contributor

    Tracking the issue at vscode-java side redhat-developer/vscode-java#479

  10. added
    votingPlease vote on the issue, so that we will take priority to this issue.
    on Jun 20, 2018
  11. testforstephen commented on Dec 2, 2021

    @testforstephen
    Contributor

    Could you try the latest Java extensions to see if the issue still exists? thanks.

  12. no-response commented on Dec 16, 2021

    @no-response

    This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions