vscode-java-debug
vscode-java-debug copied to clipboard
VSCODE wont show french accents properly (they dont even appear) even on UTF-8
[provide a description of the issue]
Environment
- Operating System: windows 10.0.19044 Build 19044
- JDK version: jdk-11.0.12.7-openj9
- Visual Studio Code version: 1.62.3
- Java extension version: 1.1.0
- Java Debugger extension version: 0.37.0 - 2021-11-24
Steps To Reproduce
I type chcp, it shows 65001 since it is the one for windows cmd to show accents. My vscode shows utf-8 in the bottom right. It wont show the accents at all, it just removes it from displaying the string. The only way to "fix it" is to do chcp 1252 which now fixes it. It used to work just fine yesterday and in the last 2 months but since i had issues with windows language keyboards it started happening.... My windows is set to accept UTF-8 worldwide language support....
Idk what to do to permanently fix it like it used to be.... The only fix I could think of is forcing chcp 1252 when I run any java files but idk what to do anymore....
I tried changing dectect locale to on/off/auto and it doesnt work either. I tried integrated or external terminal and it doesnt seem to want to force it to my CMD (I tried running a test java to see if it works on CMD and it does)
PS C:\Users\Alex\Documents\Java> & 'C:\Program Files\Semeru\jdk-11.0.12.7-openj9\bin\java.exe' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:51701' '-cp' 'C:\Users\Alex\AppData\Roaming\Code\User\workspaceStorage\546c1e2d180863c743a32792d9653675\redhat.java\jdt_ws\Java_57fe1ceb\bin' 'BIGBOSS.conceptPOO.Exercices.cours2.AlexandreP_ex04'
Current Result (Sysout)
tudiant Mathmatique
Expected Result (Sysout)
Étudiant Mathématique
Additional Informations
Could you pls take a look at the troubleshooting guide for encoding issues? https://github.com/microsoft/vscode-java-debug/blob/main/Troubleshooting_encoding.md
Thanks for the answer! Earlier today, I found a fix with someone else on reddit and a bunch of testing. I created a .ps1 profile for powershell in ~\Documents\WindowsPowerShell and added "chcp 1252 | out-null" in the profile to force it everytime my vscode opens. It feels a little bit like a jank solution but hey, if it works then it works uh...
You could add "encoding": "UTF-8" to your launch.json, that will force your Java app to use UTF-8 for IO.
BTW, VS Code also allows you to specify a profile for your terminal via user settings "terminal.integrated.profiles.windows".
You could add
"encoding": "UTF-8"to your launch.json, that will force your Java app to use UTF-8 for IO.BTW, VS Code also allows you to specify a profile for your terminal via user settings
"terminal.integrated.profiles.windows".
Mhmm I see, well its weird because at the bottom right it was on UTF-8, but i think its an issue with my powershell on my windows and maybe not directly with vscode. Anyways, it works now but if I ever get issues again ill try those solutions. Thanks Jinbo!
well it weird because at the bottom right it was on UTF-8
This is the encoding of your source files. It is not necessarily the same as the IO encoding of terminals and Java programs. The default encoding of terminals and Java program are influenced by the Windows system locale and UTF-8 worldwide language support.
For Windows users, we recommend to set your system locale to the target language to address encoding issues. See more details from https://github.com/microsoft/vscode-java-debug/blob/main/Troubleshooting_encoding.md#31-fix-suggestion--change-system-locale-to-the-target-language.
Yeah I did that already and it didnt fix it. chcp 1252 was the only fix for me for things i tried. Im on windows... It broke after I played with keyboard languages (adding / removing)
well it weird because at the bottom right it was on UTF-8
This is the encoding of your source files. It is not necessarily the same as the IO encoding of terminals and Java programs. The default encoding of terminals and Java program are influenced by the Windows system locale and UTF-8 worldwide language support.
For Windows users, we recommend to set your system locale to the target language to address encoding issues. See more details from https://github.com/microsoft/vscode-java-debug/blob/main/Troubleshooting_encoding.md#31-fix-suggestion--change-system-locale-to-the-target-language.
Ive got another problem with french accent if I may talk about it here. Using an exterior txt file with "é" "à" or any french accent in them doesnt work in the terminal. https://i.gyazo.com/01bfb2df91a5af36842ff3ac1e682b78.png
If i change chcp to 65001 it works for the words coming from the txt files but it breaks my println (any accents in them). If i put chcp to 1252 again then it works for my println but it doesnt work for the txt file anymore. Im a bit annoyed
well it weird because at the bottom right it was on UTF-8
This is the encoding of your source files. It is not necessarily the same as the IO encoding of terminals and Java programs. The default encoding of terminals and Java program are influenced by the Windows system locale and UTF-8 worldwide language support.
For Windows users, we recommend to set your system locale to the target language to address encoding issues. See more details from https://github.com/microsoft/vscode-java-debug/blob/main/Troubleshooting_encoding.md#31-fix-suggestion--change-system-locale-to-the-target-language.
Are you there? Any help to my new issue ive stated above? It weird because in active code page 65001, it works for python and C++. So it has to be the extensions for java
https://i.gyazo.com/248d60ad66572f00c2a1bf438923813b.png as seen in the picture on the right. On the windows terminal the same file shows the accent in the word "Journée" but it doesnt in vscode on the left.
@WildFearless Since your terminal code page is 65001, which is code page for UTF-8. Could you try to add a setting "java.debug.settings.vmArgs": "-Dfile.encoding=UTF-8" to your workspace .vscode/settings.json?
This will force your Java app to use UTF-8 as encoding for IO operation.
@WildFearless Since your terminal code page is 65001, which is code page for UTF-8. Could you try to add a setting
"java.debug.settings.vmArgs": "-Dfile.encoding=UTF-8"to your workspace .vscode/settings.json?This will force your Java app to use UTF-8 as encoding for IO operation.
You are actually the best. It actually fixed it (atleast for what ive tried so far). Ive set my active code page back to 65001 from 1252 and it works both for my println AND me loading a txt file without specifying which UTF code to read the file in. This is exactly what I needed, something to force my terminal in UTF-8. Thank you