Re: [php6] accepting an ascii string only

From: Date: Mon, 15 May 2006 19:42:53 +0000
Subject: Re: [php6] accepting an ascii string only
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-23411@lists.php.net to get a copy of this message
Sorry for the delay. But I think that a new type specifier could be introduced. If not you are saying to extensions writers to duplicate the code below a hundred times: if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &name, &name_len, &name_type) == FAILURE) { return; } if (name_type == IS_UNICODE) { buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC); if (buf == NULL) {
       php_error(E_WARNING, "my_var has to consist only of ASCII characters");
       RETURN_FALSE;
} } else { buf = (char *) name; } With a new specifier you would be sure that the string you received was ASCII-only and wouldn't have to care with conversions and such. Nuno
Check out ext/unicode/property.c where zend_unicode_to_ascii() is being used. -Andrei On May 9, 2006, at 12:02 AM, Derick Rethans wrote:
On Mon, 8 May 2006, Andrei Zmievski wrote:
There is no way to do it right now. I could see it being useful, though. Anyone else have an opinion on this?
I think we should have a look at it when there is a real need for it as I think it's going to be a pain for the users... Derick


« previous php.internals (#23411) next »