&#65279 - This error appears between the <body> and gives space difference

Asked

Viewed 4,010 times

5

How do I remove this error? Is causing spacing in the site header.

inserir a descrição da imagem aqui

4 answers

8


I found a very interesting solution, it’s called boom the file. This php file you can put in the root folder of your site, it is a kind of scan, which in turn accesses all the files and adjusts the GOOD values of each file.

<?php 
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
ini_set('max_execution_time', 300);

$HOME = dirname(__FILE__);

// Is this a Windows host ? If it is, change this line to $WIN = 1;
$WIN = 0;

// That's all I need
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UTF8 BOM FINDER and REMOVER</title>
<style>
body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; background: #FFF; color: #000; }
.FOUND { color: #F30; font-size: 14px; font-weight: bold; }
</style>
</head>
<body>
<?php
$BOMBED = array();
RecursiveFolder($HOME);
echo '<h2>These files had UTF8 BOM, but i cleaned them:</h2><p class="FOUND">';
foreach ($BOMBED as $utf) { echo $utf ."<br />\n"; }
echo '</p>';

// Recursive finder
function RecursiveFolder($sHOME) {
  global $BOMBED, $WIN;

  $win32 = ($WIN == 1) ? "\\" : "/";

  $folder = dir($sHOME);

  $foundfolders = array();
  while ($file = $folder->read()) {
    if($file != "." and $file != "..") {
      if(filetype($sHOME . $win32 . $file) == "dir"){
        $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file;
      } else {
        $content = file_get_contents($sHOME . $win32 . $file);
        $BOM = SearchBOM($content);
        if ($BOM) {
          $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file;

          // Remove first three chars from the file
          $content = substr($content,3);
          // Write to file 
          file_put_contents($sHOME . $win32 . $file, $content);
        }
      }
    }
  }
  $folder->close();

  if(count($foundfolders) > 0) {
    foreach ($foundfolders as $folder) {
      RecursiveFolder($folder, $win32);
    }
  }
}

// Searching for BOM in files
function SearchBOM($string) { 
    if(substr($string,0,3) == pack("CCC",0xef,0xbb,0xbf)) return true;
    return false; 
}
?>
</body>
</html>

The file you can put any.php name at the root. I hope you can help whoever is needed with this boring and boring good bug.

  • Thanks! Bro.

6

&#65279 is a special character of html, or also, codes of ISO Latin-1, which can be placed in the source code as any other alphanumeric character, to produce characters and symbols which cannot be generated with normal keyboard commands, are also known as html_entities in a brief approach.


Recommended Reading:

Special Characters in HTML

HTML Entities

5

This value (65279 == 0xFEFF) is probably a GOOD (byte-order mark) which is in your (HTML) file. Open the file in a binary editor and see if these bytes are in the file. For example, in Visual Studio, select "File -> Open", and in the "Open File" dialog, select the "Open With" option..."

inserir a descrição da imagem aqui

And select the "Binary Editor" option. If you find the bytes FEFF in the file, just remove them.

  • I opened by Editplus, but I couldn’t find...

  • I don’t know Editplus, but some "text" editors hide BOM (Ultraedit, which I use is one of them), even in Hex Viewer mode...

  • Hmmm, but I even turned the file into good + utf8, but it also doesn’t solve the problem, since there are also scripts in PHP

  • I understood Orival, but I couldn’t really find a solution, your post would perhaps be better clarify with which program I could do this, given that I don’t have the one that Carlos mentioned... I’m a little lost yet

  • Is it Visualstudio Community? @carlosfigueira

  • Hmmm OK @Dorivalzanetto - I will test your solution to see... But I have already opened in several editors and could not identify where this code is... :(

  • VS Community has this option too (I’m using VS Professional).

Show 3 more comments

5

The Character in question &#65279 is the character Unicode "zero width no-break space" (U+FEFF).

You may have copied it into your code via copy and Paste (CTRL+C and CTRL+V) without realizing it. The fact is that this is not visible if you are using a text editor whose which displays characters Unicode true.

One option is to open the file in a basic editor (for example the windows text editor) that does not interpret Unicode or one that does not interpret but can display non-ASCII characters.

After you locate the code snippet, you can delete the text block around it and rewrite it.

[Source: Stack Overflow]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.