-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
here is test code
utf8.php
<?php
require('phpQuery/phpQuery.php');
$html=<<<D
<!doctype html>
<html lang="en">
<head>
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>中文ABC</title>
</head>
<body>
</body>
</html>
D;
$doc = phpQuery::newDocumentHTML($html,'utf8');
echo $doc->find("title");result is
<title>䏿��ABC</title> addCharset
$doc = phpQuery::newDocumentHTML('<meta charset="utf8">'.$html,'utf8');
echo $doc->find("title");result is
<title>䏿��ABC</title>>Exit code: 0
the file is saved as utf8 format
DOMDocumentWrapper.php
line 155
$addDocumentCharset = false;
if ($documentCharset) {
$charset = $documentCharset;
$markup = $this->charsetFixHTML($markup);
} else if ($requestedCharset) {
$charset = $requestedCharset;
}
if (! $charset)
$charset = phpQuery::$defaultCharset;
// HTTP 1.1 says that the default charset is ISO-8859-1
// @see http://www.w3.org/International/O-HTTP-charset
if (! $documentCharset) {
$documentCharset = 'ISO-8859-1';
$addDocumentCharset = true;
}if $documentCharset no support ,can $requestedCharset overfide $documentCharset ?
can
$documentCharset is page embed contenttype meta like " "
$requestedCharset is user parameter like
$requestedCharset ='utf8';
$doc = phpQuery::newDocumentHTML($html, $requestedCharset);what's $charset stand for
the get charset logic is
page embed meta charset ?
----> user $requestedCharset; ?
---> $charset = phpQuery::$defaultCharset;
why
if (! $documentCharset) {
$documentCharset = 'ISO-8859-1';
$addDocumentCharset = true;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels