Search code examples
charsphpquery

phpQuery making  of   and others


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?


Solution

  • Â 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 “ ”