On Solaris 2.6 with ja_JP.PCK locale,
Java interpreter can't get Shift-JIS encoding characters correctly as command line arguments.
Please try these steps.
1)Login Solaris 2.6 with ja_JP.PCK locale.
2)Compile following program.
3)Execute below in command line.
%java ArgsTest A 65
%java ArgsTest ‚ 12354
%java ArgsTest l 20154
%java ArgsTest ‰N 19985
Only "A" is got correctly.
Other characters(Shift-JIS) are changed.
====== ArgsTest.java =========================================================
public class ArgsTest {
public static void main(String args[]) {
if(args.length == 0){
System.out.println("no arg");
return;
}
char line[] = new char[args.length - 1];
for(int i = 1; i < args.length; i++) {
try {
line[i-1] = (char)Integer.parseInt(args[i]);
System.out.println((int)line[i-1]);
} catch(NumberFormatException e) {
System.out.println("NFE " + e);
return;
}
}
String ns = new String(line);
if(!ns.equals(args[0])) {
System.out.println("No good:" + args[0] + "!=" + ns);
return;
}
System.out.println("okay:" + args[0] + "=" + ns);
return;
}
}
=============================================================================
Java interpreter can't get Shift-JIS encoding characters correctly as command line arguments.
Please try these steps.
1)Login Solaris 2.6 with ja_JP.PCK locale.
2)Compile following program.
3)Execute below in command line.
%java ArgsTest A 65
%java ArgsTest ‚ 12354
%java ArgsTest l 20154
%java ArgsTest ‰N 19985
Only "A" is got correctly.
Other characters(Shift-JIS) are changed.
====== ArgsTest.java =========================================================
public class ArgsTest {
public static void main(String args[]) {
if(args.length == 0){
System.out.println("no arg");
return;
}
char line[] = new char[args.length - 1];
for(int i = 1; i < args.length; i++) {
try {
line[i-1] = (char)Integer.parseInt(args[i]);
System.out.println((int)line[i-1]);
} catch(NumberFormatException e) {
System.out.println("NFE " + e);
return;
}
}
String ns = new String(line);
if(!ns.equals(args[0])) {
System.out.println("No good:" + args[0] + "!=" + ns);
return;
}
System.out.println("okay:" + args[0] + "=" + ns);
return;
}
}
=============================================================================
- duplicates
-
JDK-4229914 System.getProperty() can't get Shift-JIS property name from command line.
- Closed
- relates to
-
JDK-4011899 Java argv[] can't get some character encoding other than ascii.
- Closed