ZF-3015: Zend_Validate_StringLength use iconv extension and missing [get|set]Encoding method

Issue Type: Improvement Created: 2008-04-01T13:42:34.000+0000 Last Updated: 2008-12-21T06:17:53.000+0000 Status: Resolved Fix version(s): - 1.7.2 (23/Dec/08)

Reporter: Marc Bennewitz (GIATA mbH) (mben) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


Zend_Validate_StringLength use iconv extension but it is not documented in… and not duty to get the length of an single byte string

  • if mbstring installed -> use mb_strlen
  • elseif iconv_installed -> use iconv_strlen
  • elseif single byte encoding -> use strlen
  • else -> throw exception or detact the langth by self or use strlen


Posted by old of Satoru Yoshida ( on 2008-04-08T01:06:44.000+0000

On System i (AS/400 or i5/OS is same as System i5), iconv_strlen function does not work. I hope if Zend Framework is used on System i, Zend Framework should avoid using iconv_strlen function.

Posted by Wil Sinclair (wil) on 2008-04-18T16:55:01.000+0000

Please evaluate and categorize/assign as necessary.

Posted by Andries Seutens (andries) on 2008-10-13T10:47:44.000+0000

Marc Bennewitz:

Besides that mb_strlen is faster than iconv_strlen, there is no real difference between the two. To remain BC, i'd say we add a new method setLocale() to allow different locales to be used. The dependency will be documented as requested.

Would that work for you?

Posted by Marc Bennewitz (GIATA mbH) (mben) on 2008-10-14T01:37:44.000+0000

Hi Andries

mb_strlen sounds good but it is not available on all configurations and only a must have for multi byte encodings. I don't understand why you would add "setLocale" ? There is no encoding information. An "setEncoding" is used to check this.

On other ZF components a string information is used, too. Is it useful to create a global component to handle this ? example:

<pre class="highlight">
 + __construct($string, $encoding)
 + __toString()
 + getLength()
 + convert($encoding)
  + static strlen($string, $encoding)
  + static convert($string, $toEncoding, $fromEncoding)

Posted by Ashley Kitson (akzincdig) on 2008-10-23T00:44:40.000+0000

I have Zend Core 2.5.0 installed on a number of machines. Zend_Validate_StringLenth::isValid() fails on some machines but not others (I think it is dependent on the underlying OS variant of Linux.) Clearly as is pointed out above, reliance on the iconv extension cannot be guaranteed across every platform. Therefore alternate strlen functions are required to cope with this as suggested above.

This issue has stopped development of our system and I'd like to see this issue raised to 'Blocker' status and resolved quickly in the current 1.6 ZF stream. There are 20 occurrences of iconv_strlen in the 1.6 library and whilst we are not using all the effected code (yet), it is too much to maintain a hack version of the library to make it work for us.

Posted by old of Satoru Yoshida ( on 2008-11-06T21:22:58.000+0000

Hi, all. I find that "Zend Core for i5/OS Ver2.6.1" can handle iconv_strlen() and iconv_strpos() function.

Posted by Andries Seutens (andries) on 2008-11-08T03:53:20.000+0000


I am unable to reproduce this issue. Could you provide us with a testcase that fails?

Posted by Ashley Kitson (akzincdig) on 2008-11-10T02:40:09.000+0000

I can confirm via a conversation with Zend that Zend Core does NOT automatically enable iconv on installation in a Linux environment.

"reply I got from the Product Manager of the Core. Can you get back to me with the answer about Linux so we can get the solution for you?

"iconv extension is part of Zend Core 2.5 but is disabled by default on Linux - does he use linux? If yes, we need to check if he tried to enable it.

We plan to release and updated version of Zend Core (2.5.2) in a month, that will bundle and support the latest ZF."

You can enable iconv by enabling the extension in your php.ini file. (/usr/local/Zend/Core/etc/php.ini on a Zend Core installation)

As I responded to Zend, if Zend Core and ZF are to work together, then these inconsistencies need to be ironed out. Either ZF is built to work on the current ZC, or ZC is brought up to date to support ZF. In any event it would be prudent to augment the ZF documentation to contain a section on using it with ZC on any platform.

Posted by Thomas Weidner (thomas) on 2008-12-09T06:12:55.000+0000

This is more an improvement than a bug.

Actually this issue has to be discussed with devteam as it should be resolved with the whole ZF, not only this component.

The basic question is if we want to rely on mb* or iconv* or both.

Posted by Thomas Weidner (thomas) on 2008-12-15T11:57:46.000+0000

New feature implemented with r13278

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.