note 112830 added to domdocument.savehtmlfile

From: Date: Sat, 27 Jul 2013 16:15:52 +0000
Subject: note 112830 added to domdocument.savehtmlfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-195791@lists.php.net to get a copy of this message
saveHTMLFile() всегда сохраняет файл в кодировке UTF-8. Даже если в DOMDocument->encoding явно прописать отличную от UTF-8 кодировку. При этом все "нелатинские" символы будут преобразованы в соответствующие им HTML-сущности (HTML-entities). Проверено в PHP 5.2.9-2 и PHP 5.2.17. Пример: saveHTMLFile() always saves the file in UTF-8. Even if the DOMDocument->encoding explicitly prescribe different from UTF-8 encoding. All "non-Latin" characters will be converted to HTML-entities. Tested in PHP 5.2.9-2 and PHP 5.2.17. Example: <?php $document=new domDocument('1.0', 'WINDOWS-1251'); $document->loadHTML('<html><head><title>Russian language</title></head><body>Русский язык</body></html>'); $document->formatOutput=true; $document->encoding='WINDOWS-1251'; echo "Записано байт. Recorded bytes: ".$document->saveHTMLFile('html.html'); ?> saveHTMLFile() записала файл html.html в кодировке UTF-8. Содержимое файла html.html. Method recorded file in UTF-8 encoding. The contents of the file html.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Russian language</title> </head> <body>&ETH;&oacute;&ntilde;&ntilde;&ecirc;&egrave;&eacute; &yuml;&ccedil;&ucirc;&ecirc;</body> </html> ---- Server IP: 89.251.21.32 Probable Submitter: 89.251.21.33 (proxied: 178.216.123.184) ---- Manual Page -- http://php.net/manual/en/domdocument.savehtmlfile.php Edit -- https://master.php.net/note/edit/112830 Del: integrated -- https://master.php.net/note/delete/112830/integrated Del: useless -- https://master.php.net/note/delete/112830/useless Del: bad code -- https://master.php.net/note/delete/112830/bad+code Del: spam -- https://master.php.net/note/delete/112830/spam Del: non-english -- https://master.php.net/note/delete/112830/non-english Del: in docs -- https://master.php.net/note/delete/112830/in+docs Del: other reasons-- https://master.php.net/note/delete/112830 Reject -- https://master.php.net/note/reject/112830 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195791) next »