I have this simple PHP Program where it executes a jar that outputs a japanese word:
<?php
exec("java -jar PixivClipboardPostGet.jar", $output);
$text = $output[0];
echo $text;
?>
And here's the java file:
public class PixivClipboardPostGet {
public static void main(String[] args) {
System.out.println("日本語");
}
}
If I execute it in cmd, it prints the correct Japanese words, with chcp 932:
日本語
But when I execute it via PHP Exec, here's the output:
“ú–{Œê
I've tried numerous ways to change the encoding in the PHP so it can output the text correctly:
Attempt 1:
header('content-type: text/html; charset=utf-8');
Output:
���{��
Attempt 2:
$locale='ja-JP.utf-8';
setlocale(LC_ALL,$locale);
putenv('LC_ALL='.$locale);
Output:
���{��
I've tried exec ('chcp') just to know the code page the exec used and it correctly outputs 932, the encoding I set for my cmd.
Can anybody enlighten me to solve this problem? Thanks in advance!