note 74777 modified in domdocument.loadhtml by kalle

From: Date: Mon, 24 Mar 2014 15:41:42 +0000
Subject: note 74777 modified in domdocument.loadhtml by kalle
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-199039@lists.php.net to get a copy of this message
When using loadHTML() to process UTF-8 pages, you may meet the problem that the output of dom functions are not like the input. For example, if you want to get "Cạnh tranh", you will receive "Cạnh tranh". I suggest we use mb_convert_encoding before load UTF-8 page : <?php $pageDom = new DomDocument(); $searchPage = mb_convert_encoding($htmlUTF8Page, 'HTML-ENTITIES', "UTF-8"); @$pageDom->loadHTML($searchPage); ?> --was-- When using loadHTML() to process UTF-8 pages, you may meet the problem that the output of dom functions are not like the input. For example, if you want to get "Cạnh tranh", you will receive "Cạnh tranh". I suggest we use mb_convert_encoding before load UTF-8 page : <?php $pageDom = new DomDocument(); $searchPage = mb_convert_encoding($htmlUTF8Page, 'HTML-ENTITIES', "UTF-8"); @$pageDom->loadHTML($htmlUTF8Page); ?> http://php.net/manual/en/domdocument.loadhtml.php

« previous php.notes (#199039) next »