I use an Ajax call to receive a response in hebrew. The results come from a different site and are ISO-8859-1
encoded. My page is UTF-8
.
the response looks like Cyrillic:
îéãò ìî÷áì áæ÷ äçáøä äéùøàìéú àéï
when I try to use the header on the ajax page:
header('Content-Type: text/html; charset=ISO-8859-1');
I get this result:
îéãò ìî÷áì áæ÷ äçáøä äéùøà ìéú à éï
utf8_encode
on the response did not seem to help.
What should I do to decode correctly ?
Thanks!
Edit:
I did notice right now that the actual page that shows the data has an encoding of ISO-8859-1
, but looking in the specific header of the response with the data I see the charset is set to windows-1255
.
WHat I did now is setting the header to :
header('Content-Type: text/html; charset=windows-1255');
and on the php's side I added iconv
and simply echo:
echo iconv("WINDOWS-1255","UTF-8",$response);
The string you give in your question
Looks like the Windows 1252 (Latin I) representation of the Windows 1255 (Hebrew) codepage:
To convert that character set to UTF-8 you need to use a library that does this (e.g.
iconv
ormb_convert_encoding
) or do it by yourself.The response is not ISO-8859-1 encoded but probably windows-1255 encoded; interpreted that way, the bytes are מידע למקבל בזק החברה הישראלית אין. So try converting from windows-1255 to utf-8.
After banging my head in the wall for a while, I decided to be straightforward about it and created a mapping for the characters which worked very easily. I couldn't find a solution otherwise.
Here's the code:
I also found these resources valuable:
and this one too:
Compile PHP with
'--enable-zend-multibyte'
.then please try this
If you only need to convert.