To pass as parameter to functions that do not accept unicode (like urlencode).

Say I want to prepare a variable no create an url:

<?php
$parametervalue='abc:xyz';

$url='link.php?param='.urlencode($parametervalue);
?>

This works fine on php <=5, but on 6 it gives a warning: "urlencode() expects parameter 1 to be strictly a binary string, Unicode string given".

I need to make the variable a binary string with

$parametervalue=b'abc:xyz';

or typecast in urlencode

$url='link.php?param='.urlencode((binary)$parametervalue);

Both breaks the code in PHP <= 5, and the worst, with nothing we can do (if it would be C, we could just put some #ifdef, but this is php).

[]s
Rangel


----- Original Message ----- From: "Andrei Zmievski" <[EMAIL PROTECTED]>
To: "Rangel Reale" <[EMAIL PROTECTED]>
Cc: <internals@lists.php.net>
Sent: Wednesday, May 23, 2007 4:50 PM
Subject: Re: [PHP-DEV] PHP Unicode extension in PHP6


It would help if you provided some context. Why do you need to create
binary strings in your apps?

-Andrei


On May 23, 2007, at 5:09 AM, Rangel Reale wrote:

Yes, I understand why urlencode does not work with unicode, but the problem is, when unicode is turned on, 100% of the times I need to use it, I need to use the (binary) typecast (as normally I create my params as variables), or
create the variables as binary, all of which requires me to write  PHP 6
specific code.

Would it not be possible for the function just try to convert the string do binary itself, and issue a warning if not possible? I would of course only
use compatible strings, if I didn't, my bad.

But forcing us writing portable code for 100% incompatible source  code,
where it really isn't needed... is hard for me to undestand the  motives.

----- Original Message ----- From: "Johannes Schlüter"  <[EMAIL PROTECTED]>
To: "Rangel Reale" <[EMAIL PROTECTED]>
Cc: <internals@lists.php.net>
Sent: Tuesday, May 22, 2007 10:12 PM
Subject: Re: [PHP-DEV] PHP Unicode extension in PHP6


Hi Rangel,

for PHP 6 the basic string type ist "unicode string" and most  functions
will accept these as primary type. But there are a few exceptions  where
unicode, for different reason, makes no sense. There you have to  pass a
binary string - an example is the mentioned urlencode(): It has to  work
on bytes to be reliable but it has no clue on the proper encoding  so you
need to tell that function "Yes the, I know about the meaning,  just take
this byte sequence".

A good thing would be to check the archives where most reasons were
posted before.

johannes

On Tue, 2007-05-22 at 15:16 -0300, Rangel Reale wrote:
I'm also having problems with this b"string" incompatibility with  older
versions, I know I shouldn't need to have binary strings, but the problem is, the PHP funcions does not accept an Unicode string (urlencode), so it
gives me a warning.

In the future will 100% of the functions accept an unicode string? If so,
then to me this should not be a problem.

----- Original Message ----- From: "Tomas Kuliavas" <[EMAIL PROTECTED]>
To: "Jared Williams" <[EMAIL PROTECTED]>
Cc: <internals@lists.php.net>
Sent: Tuesday, May 22, 2007 2:52 PM
Subject: RE: [PHP-DEV] PHP Unicode extension in PHP6


> >
>> Recent versions of PHP5, has a binary string introducer.
>>
>> echo strlen(b"\xC4\x85");
>
> I have already said to Stefan. It is not an option. I need
backwards
> compatibility. If older PHP versions fail with E_PARSE errors,
I can't
> use
> it.
>
> I can't maintain two different library versions, because issue
affect
> lots
> of functions. Currently I can only stop script execution, if
> unicode.semantics=on is detected. Main complain is the fact that
> scripts
> can't control mbstring.func_overload and unicode.semantics.
Only script
> writters know, if their code depends on overloading or unicode
syntax.
> End
> users might be unable to change settings in PHP_INI_PERDIR.
>
> Thanks to all for feedback.
>
> -- > Tomas
>
> -- > PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> -- > Internal Virus Database is out-of-date.
> Checked by AVG Free Edition.
> Version: 7.5.467 / Virus Database: 269.7.1/805 - Release Date:
> 15/5/2007
> 10:47
>
>


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




--
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.1/805 - Release Date:  15/5/2007
10:47



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




--
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.1/805 - Release Date: 15/5/2007 10:47

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

Reply via email to