SYNOPSIS
--------
Japanese char (MS932) 0x5C cannot be used as an argument when quoted
OPERATING SYSTEM
----------------
Windows (Japanese)
FULL JDK VERSION
----------------
Java 8
Also reproducible with Java 7 since 7u10.
PROBLEM DESCRIPTION
-------------------
On Japanese Windows, command line argument character will be invalid (U+FFFD) if the following conditions are met.
1) The argument is enclosed by double quotes.
2) The last character of the argument is 0x5C. For example, "Katakana So" (0x835C) in MS932.
The problem only occurs if the argument is enclosed by double quotes.
The problem does NOT occur if the argument is enclosed by single quotes.
REPRODUCTION INSTRUCTIONS
-------------------------
1) Setup Japanese Windows.
2) Compile and launch the sample code with Japanese string ended 0x5C code.
> javac args.java
> java args "X"
For example, X is "Katakana So". "Katakana So" is "0x835C" in MS932.
The problem doesn't occur in the following cases.
> java args X
> java args 'X'
FAILING OUTPUT
> ?
> fffd
EXPECTED OUTPUT
> (Katakana So)
> 30bd
TESTCASE
--------
import java.util.*;
public class ArgsTest {
public static void main(String[] args){
System.out.println(args[0]);
for(int i=0; i<args[0].length(); i++){
System.out.print(Integer.toHexString((int)args[0].charAt(i)));
}
}
}