1

I'm developing a service in PHP that calls a jar file with the exec function, this way:

$text = "string with accents á, ó, ú or العربية";

exec("java -jar jarfile.jar '$text'", $data);

When I test the jar file with the command java -jar jarfile.jar "string with accents á, ó, ú or العربية" in a linux console it works well and jar file, through System.out.println, returns the text well encoded, but when executed by PHP I recive ?? where should be accented characters or arabic text.

I've tried mb_detect_encoding($data); and it says its encoding is ASCII, so I've executed $data = mb_convert_encoding($data, 'utf8', 'ASCII'); but still recieving the ?? characters.

Any help in what I should do to get characters with the right encoding?

Thank you.

DaniGC
  • 13
  • 2

1 Answers1

1

Following 2 environment works for me. You can also try it:

export LANG=en_US.UTF-8
export LOCALE=UTF-8
Ambrish
  • 3,627
  • 2
  • 27
  • 42
  • Thanks but it doesn't help in my case. – DaniGC May 19 '14 at 09:28
  • I must correct @Ambrish, your answer was right. With a wiser colleague and this http://stackoverflow.com/a/9398210/271804 we've solved. Thank you! – DaniGC May 21 '14 at 08:37