2

I'm using an API that sends and receives raw bytes.

But i have problem with displaying the Arabic words that comes over the API, it's displaying like diamond question marks "���"

I've tried to convert the string from and to utf-8.

This example returns question marks but not inside the black square "??? ???" :

String str = new String(originalStr.getBytes("ISO-8859-1"), "UTF-8");

This one returns empty string :

String str = new String(originalStr.getBytes("WINDOWS-1256"), "UTF-8");

And this one also returns an empty string :

String str = new String(originalStr.getBytes("WINDOWS-1252"), "UTF-8");

I've succeded to display the Arabic words in PHP by converting from cp1256 to utf-8 :

echo iconv('cp1256', 'utf-8', $string);

The correct character encoding for Arabic is cp1256

How can i achieve that?

Sr Julien
  • 494
  • 1
  • 8
  • 27
Amr SubZero
  • 1,196
  • 5
  • 19
  • 30

0 Answers0