I opened this bug a few months ago and I am wondering if anyone else has come across it. Unfortunately the PHP developers didn't pay much attention to it.
http://bugs.php.net/bug.php?id=46228&edit=2
http://bugs.php.net/bug.php?id=46228&edit=2