I try to print Arabic text using Java, like these:
System.out.println("طباعة نص باللغة العربية");
But the Output (in Terminal):
╪╚╟┌╔ غ╒ ╚╟طط█╔ ╟ط┌╤╚و╔
I think the problem on my terminal. Because When I try to type the same text directly in the Terminal, This is how the result looks:
I have tried these encoding: utf-8
, utf-8 with Bom
and windows1256
, but none of them worked. I am using Visual Studio code version 1.68.1
with JDK 17.0.4
.
I also edited settings.json
file as follows:
The purpose is to print the text correctly. So, how can I print the string or content of text correctly in its original form? like:
طباعة نص باللغة العربية
The answers and comments above have pointed out that this may be related to the terminal encoding and file encoding format, and have given a valid solution.
Here are some of my suggestions that may be useful to you:
Install the Code Runner extension
Use Run Code
option to run the code
Output the results in the OUTPUT panel
Configure launch.json as follows
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}",
"console": "internalConsole"
},
]
}
Start debugging in the Run and Debug window
Debug results are displayed in the DEBUG CONSOLE panel