Programing

HTML에 왜가 나타 납니까?

lottogame 2020. 6. 22. 07:49
반응형

HTML에 왜가 나타 납니까? [복제]


이 질문에는 이미 답변이 있습니다.

Firebug에서이 캐릭터를 봅니다 .

왜 이런 일이 일어나고 있는지 모르겠습니다. 내 코드에는 그러한 문자가 없습니다. Firefox의 경우 문제가 없지만 IE에서는 모든 것이 깨집니다. Google에서이 캐릭터를 검색 할 수도 없습니다.

bom없이 utf-8 인코딩으로 파일을 저장했습니다.

여기에 이미지 설명을 입력하십시오


해당 문자 &#65279는 유니 코드 문자 'ZERO WIDTH NO-BREAK SPACE'(U + FEFF)입니다. 복사하지 않고 복사 / 붙여 넣기를 통해 코드에 복사했을 수도 있습니다. 표시되지 않기 때문에 실제 유니 코드 문자를 표시하는 편집기를 사용하고 있는지 알기가 어렵습니다.

하나의 옵션은 유니 코드를 이해하지 못하는 매우 기본적인 텍스트 편집기 나 파일을 이해하지만 실제 코드를 사용하여 ASCII 이외의 문자를 표시 할 수있는 매우 기본적인 텍스트 편집기에서 파일을 여는 것입니다.

찾은 다음 주위의 작은 텍스트 블록을 삭제하고 해당 텍스트를 수동으로 다시 입력 할 수 있습니다.


BOM없이 UTF-8을 인코딩하는 메모장 ++를 사용하십시오.


예, 메모장 ++로 파일을 열고 BOM없이 UTF-8 인코딩 UTF-8 단계를 수행하십시오. 그런 다음 저장하십시오. 그것은 나에게도 효과적입니다!


시험:

<?php 
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
$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>

이 코드를 PHP 파일에 복사하여 루트에 업로드하고 실행하십시오.

이에 대한 자세한 내용은 http://forum.virtuemart.net/index.php?topic=98700.0


"왜 이런 일이 일어나는지 모르겠다"

Well I have just run into a possible cause:-) Your HTML page is being assembled from separate files. Perhaps you have files which only contain the body or banner portion of your final page. Those files contain a BOM (0xFEFF) marker. Then as part of the merge process you are running HTML tidy or xmllint over the final merged HTML file.

That will cause it!


If you are using Notepad++, "Menu" >> "Encoding" >> "Convert to UTF-8" your "include" files.


If you have a lot of files to review, you can use this tool: https://www.mannaz.at/codebase/utf-byte-order-mark-bom-remover/

Credits to Maurice

It help me to clean a system, with MVC in CakePhp, as i work in Linux, Windows, with different tools.. in some files my design was break.. so after checkin in Chrome with debug tool find the &#65279 error


Before clear space (trim)

Then replace with RegEx .replace("/\xEF\xBB\xBF/", "")

I'm working on Javascript, I did with JavaScript.


An old stupid trick that works in this case... paste code from your editor to ms notepad, then viceversa, and evil character will disappears ! I take inspiration from wyisyg/msword copypaste problem. Notepad++ utf-8 w/out BOM works as well.


여기에 2 센트가 있습니다. 같은 문제가 있었으며 메모장 ++을 사용하여 UTF-8로 BOM을 변환하지 않았으며 오래된 "MS 메모장으로 복사 한 다음 다시 다시 복사"트릭을 사용하지 못했습니다. 내 문제는 모든 파일 (및 '포함 된'파일)이 동일한 파일 시스템 인지 확인하여 해결되었습니다 . Windows 형식의 일부 파일과 원격 Linux 서버에서 복사 된 일부 파일이 UNIX 형식이었습니다.

참고 URL : https://stackoverflow.com/questions/9691771/why-is-65279-appearing-in-my-html

반응형