note 117190 added to domdocument.savehtml
| From: | RiKdnUA at mail dot ru | Date: | Wed, 29 Apr 2015 15:49:35 +0000 |
| Subject: | note 117190 added to domdocument.savehtml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202394@lists.php.net to get a copy of this message | ||
Tested in PHP 5.2.9-2 and PHP 5.2.17.
saveHTML() игноÑиÑÑÐµÑ ÑвойÑÑво
DOMDocument->encoding. ÐеÑод saveHTML() ÑоÑ
ÑанÑеÑ
html-докÑÐ¼ÐµÐ½Ñ Ð² кодиÑовке,
коÑоÑÐ°Ñ Ñказана в Ñеге <meta>
иÑÑ
одного (загÑÑженного)
html-докÑменÑа.
saveHTML() ignores property DOMDocument->encoding. Method saveHTML() saves the html-document
encoding, which is specified in the tag <meta> source (downloaded) html-document.
Example:
file.html. ÐодиÑовка Ñайла должна
ÑовпадаÑÑ Ñ Ñказанной в Ñеге
<meta>. The encoding of the file must match the specified tag <meta>.
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Russian language</title></head>
<body>Ð ÑÑÑкий ÑзÑк</body></html>
<?php
error_reporting(-1);
$document=new domDocument('1.0', 'UTF-8');
$document->preserveWhiteSpace=false;
$document->loadHTMLFile('file.html');
$document->formatOutput=true;
$document->encoding='UTF-8';
$htm=$document->saveHTML();
echo"ÐапиÑано байÑ. Recorded bytes:
".file_put_contents('file_new.html', $htm);
?>
file_new.html бÑÐ´ÐµÑ Ð² кодиÑовке Windows-1251 (ÐÐ
в UTF-8).
file_new.html will be encoded in Windows-1251 (not in UTF-8).
saveHTML() и file_put_contents() позволÑÑÑ
пÑеодолеÑÑ Ð½ÐµÐ´Ð¾ÑÑаÑок
меÑода saveHTMLFile().
СмоÑÑиÑе мой комменÑаÑий к
меÑÐ¾Ð´Ñ saveHTMLFile().
saveHTML() and file_put_contents() allows you to overcome the lack of a method saveHTMLFile().
See my comment on the method saveHTMLFile().
http://php.net/manual/ru/domdocument.savehtmlfile.php
----
Server IP: 72.52.91.14
Probable Submitter: 178.216.123.184
----
Manual Page -- http://php.net/manual/en/domdocument.savehtml.php
Edit -- https://master.php.net/note/edit/117190
Del: integrated -- https://master.php.net/note/delete/117190/integrated
Del: useless -- https://master.php.net/note/delete/117190/useless
Del: bad code -- https://master.php.net/note/delete/117190/bad+code
Del: spam -- https://master.php.net/note/delete/117190/spam
Del: non-english -- https://master.php.net/note/delete/117190/non-english
Del: in docs -- https://master.php.net/note/delete/117190/in+docs
Del: other reasons-- https://master.php.net/note/delete/117190
Reject -- https://master.php.net/note/reject/117190
Search -- https://master.php.net/manage/user-notes.php