note 98213 added to domdocument.load
| From: | _michael at osu1 dot php dot net | Date: | Tue, 01 Jun 2010 15:34:32 +0000 |
| Subject: | note 98213 added to domdocument.load | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169808@lists.php.net to get a copy of this message | ||
load() will handle non-ASCII characters depending on the details of the XML declaration, but in a
somewhat surprising way. One would assume that the declarations '<?xml
version="1.0" encoding="UTF-8"?>' and '<?xml
version="1.0"?>' are treated in the same way because UTF-8 is the default encoding
anyway. But not so.
* If there is an XML declaration defining the encoding *explicitly*, the non-ASCII characters remain
unchanged.
* If the XML declaration does not define the encoding explicitly, or if the XML declaration is
missing, non-ASCII characters are converted into numeric entities.
So the document
<?xml version="1.0"?>
<root><nonascii>ä</nonascii></root>
will be converted to
<?xml version="1.0"?>
<root><nonascii>ä</nonascii></root>
The same happens if there is no XML declaration at all. On the other hand, the document
<?xml version="1.0" encoding="UTF-8"?>
<root><nonascii>ä</nonascii></root>
will remain as it is.
This behaviour applies to loadXML() as well.
----
Server IP: 217.160.235.204
Probable Submitter: 91.57.106.39
----
Manual Page -- http://www.php.net/manual/en/domdocument.load.php
Edit -- https://master.php.net/note/edit/98213
Del: integrated -- https://master.php.net/note/delete/98213/integrated
Del: useless -- https://master.php.net/note/delete/98213/useless
Del: bad code -- https://master.php.net/note/delete/98213/bad+code
Del: spam -- https://master.php.net/note/delete/98213/spam
Del: non-english -- https://master.php.net/note/delete/98213/non-english
Del: in docs -- https://master.php.net/note/delete/98213/in+docs
Del: other reasons-- https://master.php.net/note/delete/98213
Reject -- https://master.php.net/note/reject/98213
Search -- https://master.php.net/manage/user-notes.php