DEVSENSE / Phalanger

PHP 5.4 compiler for .NET/Mono frameworks. Predecessor to the opensource PeachPie project (www.peachpie.io).
http://v4.php-compiler.net/
Apache License 2.0
382 stars 94 forks source link

mbstring serialize/unserialize incorrect behaviour compared to PHP #68

Open lucyllewy opened 7 years ago

lucyllewy commented 7 years ago

serializing a multibyte character and then unserializing it again in Phalanger causes character to change when echoed as shown in the testcase below.

Phalanger behaves differently to PHP in this respect:

<?php
$val1 = 'é';
$val2 = unserialize(serialize($val1));

$EOL = "<br>\n";

// let's test equality of the supposedly equal characters
echo ($val1 === $val2 ? 'Equal' : 'Not Equal') . $EOL; // Returns 'Equal', because $val1 === $val2 === 'é'
echo htmlentities($val1) . $EOL; // Returns html entity for 'é'
echo htmlentities($val2) . $EOL; // Returns '?' (Note that $val1 === $val2 !)
jakubmisek commented 7 years ago

serialize/unserialize translates unicode strings according to current PageEncoding which is set to default windows culture by default. I would always recommend to set PageEncoding to UTF-8 to avoid all these issues.