Re: [PATCH] Bug #43896 htmlspecialchars returns empty stringoninvalid unicode sequence

From: Date: Tue, 29 Jan 2008 02:24:30 +0000
Subject: Re: [PATCH] Bug #43896 htmlspecialchars returns empty stringoninvalid unicode sequence
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-34992@lists.php.net to get a copy of this message
On Mon, 28 Jan 2008 17:26:48 -0800, in php.internals rasmus@lerdorf.com (Rasmus Lerdorf) wrote: >php -r '$a="abcd".chr(0xE0);echo >iconv("utf-8","utf-8",$a)."\n".utf8_decode($a);' | od -t x1 > >0000000 61 62 63 64 0a 61 62 63 64 03 By the way, the 03 in your result is a bit spurious. For me it seems to differ every time I run that code. It happens with 0xE0 but not with e.g. 0xE6 (æ). It seems to be consistent for every run though: $ php -r 'for($a=0;$a<20;$a++)printf("%02x ",utf8_decode(chr(0xE0)));' 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 $ php -r 'for($a=0;$a<20;$a++)printf("%02x ",utf8_decode(chr(0xE0)));' 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 $ php -r 'for($a=0;$a<20;$a++)printf("%02x ",utf8_decode(chr(0xE0)));' 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 $ php -r 'for($a=0;$a<20;$a++)printf("%02x ",utf8_decode(chr(0xE0)));' 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 $ for a in seq 1 20; do php -r 'printf("%02x ",utf8_decode(chr(0xE0)));'; done 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 $ for a in seq 1 20; do php -r 'printf("%02x ",utf8_decode(chr(0xE0)));'; done 08 00 00 02 00 00 00 00 00 05 00 00 00 05 00 00 07 00 09 00 $ for a in seq 1 20; do php -r 'printf("%02x ",utf8_decode(chr(0xE0)));'; done 00 00 00 00 00 00 00 00 04 00 08 00 00 00 00 05 00 00 01 00 I don't think there is any reason for this behaviour. I'll file a bug. -- - Peter Brodersen

« previous php.internals (#34992) next »