I have a page in my website which gets it's main content from an old mainframe. The content encoding from the mainframe is windows-1255 (Hebrew). My website's encoding is UTF-8.
At first I used an iframe to display the received answer from the mainframe. In that solution I had no problem setting the encoding of the page and the characters display was fine, but I had some problems styling the page responsively (My all website is responsive).
Then I tried fetching the content with file_get_contents
and add it in the right place, but all the characters look like this: ����� ��, I then converted the content:
iconv("cp1255","UTF-8",file_get_contents("my_url"));
The result of that was reversed Hebrew. For example the word "nice" appears as "ecin".
The content also includes HTML tags, not only Hebrew text, so I can't simply reverse the text with hebrev
.
I saw that in PHP 4 the function fribidi_log2vis exists, which seems to solve my problem, but it's not supported in PHP 5 (I'm working with PHP 5.3.3).
Is there a way handling it better than loading the content into an iframe?
UPDATE
I tried to fetch a test file that I created (with encoding windows-1255) and my original code works OK. I suspect that the content I'm getting is not windows-1255, at least not in the terms of Hebrew letters order. The conversion on the mainframe might be the cause. I'll have to look into that (I have to wait until Sunday cause I don't have a direct access to the server).
preg_replace_callback
. Secondly, it appears as if the content coming from the mainframe is notcp1255
, or the content contains somebidi
symbols, which control the text direction. Anyhow it's hard to tell from here, but if you could upload an example file content we might be able to help further – Teleology