CodeIgniter Forums
ASCII 239 problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ASCII 239 problem (/showthread.php?tid=11690)



ASCII 239 problem - El Forum - 09-19-2008

[eluser]Volder[/eluser]
Hello,
I'm facing the following problem.

I created a small view file:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

&lt;html &gt;

&lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
    &lt;style&gt;#topborder {height: 10px;
                       background-color: red;}&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
<div id="topborder"></div>
&lt;/body&gt;
&lt;/html&gt;
and a simple controller for viewing it:
Code:
&lt;?php

class Test extends Controller{


  function index()
  {
   $this->load->view('v_test');
  }
}

but when I loaded '/test' page - the red line is not on the top of the window.
So there is a space between browser's top border and my <div> element.

But the following controller works fine:
Code:
&lt;?php

class Test extends Controller{


  function index()
  {
   $buffer = $this->load->view('v_test','',TRUE);
   echo $buffer;
  }
}

as I found there is an ASCII character 239 appeared at the beginnig of the file.
So I thought about BOM, but there is only one character - not three of them.
All my files are saved as UTF-8 without BOM.

I'm using UTF-8 by default.
OS Windows XP.
Apache/2.2.9 (Win32)
PHP 5.2.6
Codeigniter 1.6.3

I read a lot of forums and still have not found a solution.
Maybe someone here has met such a probelm before?


ASCII 239 problem - El Forum - 04-27-2011

[eluser]Unknown[/eluser]
I know this thread is long since dead, but I had the same kind of problem using a different php framework and I wanted to post a solution for others.

The cause of the problem is that the template file is encoded in UTF-8. Changing it to a different encoding, like ANSI, makes the mystery character go away.

There may be another way, like setting php to play better with UTF-8 files, but this solved my immediate problem.


ASCII 239 problem - El Forum - 04-27-2011

[eluser]InsiteFX[/eluser]
It's not a problem, the problem is when you copy the file and paste in to a new html document then change it to utf8 with no BOM the character will still be there!

Or when you already have the html document and then you change it to utf8 with no BOM the character will still be there because it is saved with the document!

The correct way is to create a new html document with utf8 and no BOM, then paste the code into it.
I do this all of the time and have no problems.

InstieFX