note 46274 added to ref.simplexml

From: Date: Tue, 05 Oct 2004 11:58:54 +0000
Subject: note 46274 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-78020@lists.php.net to get a copy of this message
When using the function 'simplexml_load_file() ', be aware that when php parses the XML, it autimatically encodes all elements and attributes (content) to the UTF-8 standard. This means that all non-standard characters, such as Danish or Norwegian characters 'æ', 'ø', 'å', German characters ä, ö, é, á etc., are converted to UTF-8 (æ, ø, å = æ, ø, Ã¥). Therefore, to decode the content use the php function: utf8_decode() Simple function for easy typecasting and UTF-8 decoding: function typecast($var) { switch($type) { case "object": $var = (object) $var; break; case "int": $var = (integer) $var; break; case "float": $var = (float) $var; break; case "double": $var = (double) $var; break; case "int": $var = (integer) $var; break; case "string": // Decode UTF-8: $var = utf8_decode($var); $var = (string) $var; break; default: // Decode UTF-8: $var = utf8_decode($var); $var = (string) $var; break; } return $var; } ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46274 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46274&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46274&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78020) next »