title: Converting windows-1255 to UTF-8 in PHP 5
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>Then I tried fetching the content with <code>file_get_contents</code> and add it in the right place, but all the characters look like this: ����� ��, I then converted the content:</p>
  
  <pre><code>iconv("cp1255","UTF-8",file_get_contents("my_url"));
  </code></pre>
  
  <p>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 <code>hebrev</code>.</p>
  
  <p>I saw that in PHP 4 the function <a href="http://www.php.net/manual/en/function.fribidi-log2vis.php" rel="noreferrer">fribidi_log2vis</a> exists, which seems to solve my problem, but it's not supported in PHP 5 (I'm working with PHP 5.3.3).</p>
  
  <p>Is there a way handling it better than loading the content into an iframe?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>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).</p>