Net_IDNA class names
| From: | Benjamin Muskalla | Date: | Sun, 07 Aug 2005 13:37:48 +0000 |
| Subject: | Net_IDNA class names | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-39269@lists.php.net to get a copy of this message | ||
Hi list!
Yesterday I wanted to try the Net_IDNA package. But i found serveral
problems in this package.
First, the IDNA.php is a singleton wrapper to get the php4/php5 class of
the converter. Here is a snippet from the IDNA class:
function &getInstance($params = array())
{
$version = explode( '.', phpversion() );
$handler = ((int)$version[0] > 4) ? 'php5' : 'php4';
$class = 'Net_IDNA_' . $handler;
$classfile = 'Net/IDNA/' . $handler . '.php';
/*
* Attempt to include our version of the named class, but don't
treat
* a failure as fatal. The caller may have already included
their own
* version of the named class.
*/
@include_once $classfile;
/* If the class exists, return a new instance of it. */
if (class_exists($class)) {
return new $class($params);
}
return false;
}
IMHO thats means that the classfiles (Net/IDNA/php4|5.php) will be
loaded and then try to load the classes 'Net_IDNA_php4|5'. But the
classes are called Net_IDNA (php5) (=> Fatal error because the classname
cannot be redeclared) and idna_convert (php4) (=> classname is not
found). So this ends up with an fatal error.
If you load the class yourself with
include('Net/IDNA/php5.php'), it works well.
Only thing to do is to rename the classes to Net_IDNA_php4 and
Net_IDNA_php5.
Next thing is that i want to encode an ISO-8851-1 string. Due the
documentation, i should set the parameter utf8 to false. see
* [utf8 - Use either UTF-8 or ISO-8859-1 as input (true for UTF-8,
false otherwise); The output is always UTF-8]
But i only get the following error:
Conversion from UTF-8 to UCS-4 failed: malformed input at byte X
But as I said before, I had set the paramter utf8 to false.
Third problem is the use of $this->_error because it is not declared. It
should be replaced with a new Exception. If you want, I'll write a patch
for that when Net_IDNA is in cvs (y i isn't there yet?)
greets,
benny