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.

1 Answer 1

1

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

export LANG=en_US.UTF-8
export LOCALE=UTF-8
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks but it doesn't help in my case.
I must correct @Ambrish, your answer was right. With a wiser colleague and this stackoverflow.com/a/9398210/271804 we've solved. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.