I have come across a strange issue. In the below piece of code, I am searching for the presence of ß.
public static void main(String[] args) {
char [] chArray = {'ß'};
String str = "Testß";
for(int i=0; i<chArray.length; i++){
if(str.indexOf(chArray[i])>-1){
System.out.println("ß is present");
break;
}
}
}
I have a web application running on JBOSS in linux, Java 6. The above code doesn't detect the presence of ß when include the code in the above specified application. Surprisingly, if I compile the same file in my eclipse workspace and then apply the patch in the application it runs as expected!
Points to note:
- The application build environment is a black-box to me, hence no idea if there is any -encoding option is present for the javac command or something like that
- My eclipse's JRE is java8, but the compiler version set for the project is Java6
I changed the value from ß to unicode equivalent to \u00DF in the array declaration, but still the behavior is same.
char [] chArray = {'\u00DF'};
When I decompiled the class file generated the character array declared value was shown as 65533, which is \uFFFD, nothing but replacement character which is used for unidentified symbol. I used JD-GUI as decompiler, which I dont see trustworthy!
Need your help folks! I am sure it is not same as: case sensitive issue of beta Java's equalsIgnoreCase fails with ß ("Sharp S" used in German alphabet)
Thanks in advance