I am trying to pass a UTF-8 string as a command line parameter from PHP to a Java program. When I view the string in the PHP debugger, it show correctly: Présentation
Yet when I look at the arg[0] data in the Java debugger (and the returned value passed back to the PHP program) I see: Pr??sentation
I have tried the Java code below and neither ISO_8859_1 nor UTF_8 return the proper results.
I've looked here on stackoverflow (Translate UTF-8 character encoding function from PHP to Java) as well as other sites and still cannot make sense at what I am doing wrong.
Everything seems to work find in PHP yet Java is doing something right from the start with the data that looks like it needs perhaps additional processing after or before I call the code below.
This is my first go at dealing with international characters. Any help is greatly appreciated. Thank you!
Edit: I am debugging on Windows remotely - the PHP and Java are being run on an Ubuntu system. But since the PHP code and Java code called from the PHP code reside on the linux based system, there should not be any issue with Windows command line Java and UTF-8. I had read here on stackoverflow that was an issue for some in the recent past.
byte[] test_str_1 = args[0].getBytes(StandardCharsets.ISO_8859_1);
System.out.println(test_str_1);
byte[] test_str_2 = args[0].getBytes(StandardCharsets.UTF_8);
System.out.println(test_str_2);