Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting in VSCode results in garbled characters when there is Chinese text. #370

Open
zhangmsh opened this issue Mar 30, 2023 · 5 comments

Comments

@zhangmsh
Copy link

I am using version 0.0.38 of VSCode. When formatting code in JAVA, if there is Chinese text, the text will become garbled. I have tried using RedHat Formatter and it works fine.

settings:

java.format.settings.profile": "D:\\soft\\work-tools\\Microsoft VS Code\\code.xml",
"[java]": {
        "editor.defaultFormatter": "io.spring.javaformat.spring-javaformat-vscode-extension"
    },
   

How can I solve this issue? I am looking forward to your reply.
Thank you very much.

@philwebb
Copy link
Contributor

philwebb commented Apr 5, 2023

I suspect we've missed something with the character encoding. @zhangmsh are you able to provide a sample project that shows the issue?

@wilkinsona
Copy link
Contributor

Closing due to the lack of request feedback. We can re-open and investigate if a sample project is provided.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2023
@persapiens
Copy link

persapiens commented Feb 4, 2024

hi @philwebb and @wilkinsona ,

I have the same problem when I save any Java file with Portuguese characters like 'ã' or 'ç'.
For example, the text "Demonstração+do+Resultado" becomes "Demonstra��o+do+Resultado".
Visual Code 1.86.0 is configured to auto-format on save with encoding utf-8.
This error only happens when I use Spring Java Format Visual Code Extension 0.0.41 on Windows (encoding Windows-1252).
Other Formatters work ok.

I also see that Spring Java Format Visual Code Extension works ok if I execute the same procedure on codespace (Linux encoding utf-8). The Java file keeps the characters.

I look forward to your answer.

@philwebb
Copy link
Contributor

@persapiens Are you able to provide a sample and detail the steps needed to reproduce the issue?

@persapiens
Copy link

persapiens commented Feb 16, 2024

Hi @philwebb ,

I uploaded a sample project here:

  • I created the project using start.spring.io with the following options: maven, java language, spring boot 3.2.2, packaging jar, and java 21. It was the first commit of the repository.
  • I downloaded Spring Java Format VSCode extension 0.0.41.
  • Inside VS Code 1.86.2 using Windows 10 Pro 21H1 (Portuguese Brazil as the default language), I installed the Spring Java Format VSCode Extension.
  • I configured VSCode to format on save editing. It was the second commit of the repository.
  • Inside VSCode, I commented on the DemoApplication class using Portuguese characters with accents:
/**
 * Spring Boot is fantastic. (pt-Br) Spring Boot é fantástico.
 */
  • When I save the file with 'Ctrl + S' in the last commit, the comment becomes (I use "editor.formatOnSave": true):
/**
 * Spring Boot is fantastic. (pt-br) Spring Boot � fant�stico.
 */

Best wishes.

@wilkinsona wilkinsona reopened this Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants