As PHP is loosely typed, "1"==1 is fine.

Is it that with Unicode, this looseness is gone?



On 29/05/07, Pierre <[EMAIL PROTECTED]> wrote:
Hi,

On 5/29/07, David Coallier <[EMAIL PROTECTED]> wrote:
> On 5/29/07, Antony Dovgal <[EMAIL PROTECTED]> wrote:
> > Hello.
> >
> > Do you think the engine should support bitwise operators and Unicode 
strings?
> > If yes, how do you think it should work?
> >
> > Example:
> > <?php
> > $a = "1";
> > $a|="2";
> > var_dump($a);
> > ?>
> >
> > This code outputs "3" in native mode and "Fatal error: Unsupported operand 
types" in Unicode mode.
> > I believe this is an inconsistency and it should be possible to use Unicode 
strings there.
>
> Definitely
>
> >
> > There are several possible ways to implement it:
> > 1) the same as with native strings - apply the operator to each element of 
the string separately;
> > 2) convert the string to binary (using say iso-8859-1) and then see 1);
>
> I would probably be for the solution #2 and of course using the
> unicode.runtime_encoding ini setting to convert it to binary.
>
>
> >
> > We can also leave it as is (since it doesn't seem very useful) or even drop 
the native strings support (it doesn't seem very useful to me either).
>
> I think this is a bad choice.. might not be useful to you, but might
> be to some other people

I fail to see or imagine any useful usages for such hacks. Laziness
justifies it with binary strings (as in 5.x), but as long as an
unicode string is given, one should really first cast to integer
before using it with a bitwise operator (or any other non string
operation).

I'm in favour of keeping the current behaviors and drop the native
support as well for consistency (and documentation/wtf headaches).

--Pierre

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php




--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to