3 foreach(array('UTF-8', 'UCS-2LE') as $targetCharset) {
4 $s = fopen('php://memory', 'rw');
5 fwrite($s, "\xe9"); // euro currency symbol in ISO-8859-1
7 stream_filter_append($s, "convert.iconv.ISO-8859-1/$targetCharset");
8 $utf8Symbol = stream_get_contents($s);
9 echo 'Euro symbol in ' . $targetCharset;
10 echo ' has content "' . bin2hex($utf8Symbol) . '"';
11 echo ' and size ' . strlen($utf8Symbol) . 'b', "\n";