note 46274 deleted from ref.simplexml by nlopess
| From: | nlopess@php.net | Date: | Tue, 05 Oct 2004 15:46:30 +0000 |
| Subject: | note 46274 deleted from ref.simplexml by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78028@lists.php.net to get a copy of this message | ||
Note Submitter: mikkel at rostock dot biz
----
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;
}