PHP6 artifact - binary strings
| From: | Marc Bennewitz | Date: | Sun, 08 Feb 2015 20:10:53 +0000 |
| Subject: | PHP6 artifact - binary strings | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-82167@lists.php.net to get a copy of this message | ||
Hi all,
Since PHP-5.2.1 we have an artifact of PHP-6 in the engine means we can define binary strings but such definitions haven't any effect.
So what we can define is the following:
$str = "str";
$bin = b"b\0i\0n";
$str2bin = (binary)$str;
One of the biggest issue is that currently ALL strings will be handled as ASCII-7 compatible strings on type-juggling but they aren't.
It would be very appreciated if PHP could respect such binary declaration:
* use binary string comparison on compare a binary string to any other string
* don't convert binary strings into integers on array keys
* allow bitwise operators on binary strings without casting to integer
I don't wont to open such unicode nightmare as it was planned for PHP-6!
In my opinion the above operator changes are enough and therefore internal functions doesn't need to be changed in the first place. The only changes *could* be done to functions reading/parsing data to be auto marked binary like: unpack, stream reading functions opened with fopen + "b" ...
I don't have enough zend experience and therefore I would like to know how complicated it would be.
Thoughts?
Marc