问题
I have this simple code that prints Arabic sentence and scan arabic characters .
what is drivingme crazy is that it prints in cmd right , but never scan characters it scans arabic characters in form of
��� �����
I tried everything: Scanner(System.in,"UTF-8")
, Scanner(System.in,"UTF8");
please help
public static void main(String[] args) {
Scanner in2 = new Scanner(System.in,"UTF-8");
System.out.printf(" ادخل جملة السؤال \n");
String s = in2.nextLine();
System.out.printf(""+s+"");
// TODO code application logic here
} Scanner in2 = new Scanner(System.in,"UTF-8");
System.out.printf(" ادخل جملة السؤال \n");
String s = in2.nextLine();
System.out.printf(""+s+"");
output :
ادخل جملة السؤال هذا تلميذ ��� �����
BUILD SUCCESSFUL (total time: 11 seconds)
回答1:
i have the same problem with netbeans 8 and windows 7
to fix this please do that
open
C:\Program Files\NetBeans 8.0\etc\netbeans.conf
you will find this
netbeans_default_options="..."
add this code at the begining of it so at the end it will look like that
netbeans_default_options="-J-Dfile.encoding=UTF-8 -J-client ..."
and restart the netbeans
check this screen shot

回答2:
Don't worry about that, it is the IDE's problem. Most IDEs console window don't support other that ASCII, but In real life Swing, this will appear as usual.
回答3:
I faced this issue in Windows Server 2016.
Solution: 1. Go to Control Panel -> Region. 2. Open Administrative tab. 3. Click “Change System Local” to Arabic. 4. Restart the server.
来源:https://stackoverflow.com/questions/29076145/scan-in-arabic-characters-netbeans-8