2

When I have a file that I run through phpQuery that has stuff like   or © in it somehow a  is added.

so when I have this file (hello.html):

hello, this is a test ©

and I run this code:

$f = phpQuery::newDocumentFile( 'hello.html' );
echo $f->html();

I get the following output:

hello, this is a test ©

Is there something I can do to fic this?

patrick
  • 11,519
  • 8
  • 71
  • 80
  • Try saving your PHP file with UTF-8 without BOM encoding. You can do this with an editor like Notepad++ – Straseus Mar 22 '12 at 22:58
  • 1
    Related Question: http://stackoverflow.com/questions/3589358/fix-incorrectly-displayed-encoding-on-an-html-document-with-php – Straseus Mar 22 '12 at 22:58

1 Answers1

1

 shows up because of encoding issues, I would try converting it from ISO-8859-1 to UTF-8 using utf8_encode

$markup = file_get_contents('hello.html');
$utf8_markup = utf8_encode($markup);
$doc = phpQuery::newDocumentHTML($utf8_markup);

This is a related post HTML encoding issues - “” character showing up instead of “ ”

Community
  • 1
  • 1
r-sal
  • 1,169
  • 8
  • 9
  • sorry, but did you read the question? Let me explain: phpQuery is a library, if I let a page run through that I get these unwanted results. This has nothing to do with htmlentities... – patrick Jan 09 '13 at 12:45
  • 1
    I should have read the question better, I'm not positive if I have the answer but I added to my post above, I would try that out – r-sal Jan 09 '13 at 13:41