note 78243 added to function.dom-domdocument-loadhtml
| From: | xuanbn at yahoo dot com | Date: | Thu, 04 Oct 2007 08:38:12 +0000 |
| Subject: | note 78243 added to function.dom-domdocument-loadhtml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131070@lists.php.net to get a copy of this message | ||
If you use loadHTML() to process utf HTML string (eg in Vietnamese), you may experience result in
garbage text, while some files were OK. Even your HTML already have meta charset like
<meta http-equiv="content-type" content="text/html; charset=utf-8">
I have discovered that, to help loadHTML() process utf file correctly, the meta tag should come
first, before any utf string appear. For example, this HTML file
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title> Vietnamese - Tiếng Viá»t</title>
</head>
<body></body>
</html>
will be OK with loadHTML() when <meta> tag appear <title> tag.
But the file below will not regcornize by loadHTML() because <title> tag contains utf string
appear before <meta> tag.
<html>
<head>
<title> Vietnamese - Tiếng Viá»t</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body></body>
</html>
----
Server IP: 69.147.83.197
Probable Submitter: 117.0.66.206
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-loadhtml.php
Edit -- https://master.php.net/note/edit/78243
Del: integrated -- https://master.php.net/note/delete/78243/integrated
Del: useless -- https://master.php.net/note/delete/78243/useless
Del: bad code -- https://master.php.net/note/delete/78243/bad+code
Del: spam -- https://master.php.net/note/delete/78243/spam
Del: non-english -- https://master.php.net/note/delete/78243/non-english
Del: in docs -- https://master.php.net/note/delete/78243/in+docs
Del: other reasons-- https://master.php.net/note/delete/78243
Reject -- https://master.php.net/note/reject/78243
Search -- https://master.php.net/manage/user-notes.php