Hi Shahar,

This operation may fit nicely as:

class Zend_Filter_StringByteLength implements Zend_Filter_Interface
{
    /**
     * Returns the length in bytes of the string $value
     *
     * @param  string $value
     * @throws Zend_Filter_Exception If determining byte length is
impossible
     * @return integer
     */
    public function filter($value)
    {
        /**
         * @todo Implementation
         */
    }
}

or something similar?

Best regards,
Darby

Shahar Evron wrote:
> Hi all,
> 
> I am working on one of the Http_Client bugs, ZF-2098, which describes a
> problem the Http_Client has when sending multi-byte encoded (eg. UTF8
> Chinese) text in the request body when mbstring is loaded and overloads
> the strlen() function. This happens because I've been using strlen() to
> calculate the body size (in bytes - not in characters). 
> 
> This works in most cases, but when mbstring overloads strlen with
> mb_strlen - what you get is the string length in characters and not in
> bytes. 
> 
> Brian DeShong already proposed a patch fixing the problem, but I've
> found that there are several Zend_Http classes that suffer from the same
> problem. I'm sure that other ZF classes, as well as users, who need a
> transparent way to calculate string length in bytes, irregardless of
> loaded extensions or PHP version (no idea what PHP 6 / 5.3 would cause
> in this case). 
> 
> So, is there any component of the framework where you would see a
> static ::strByteLength($string) method? I was going to implement one in
> Zend_Http_Client - but it's not really Zend_Http_Client specific. 
> 
> Suggestions welcome ;)
> 
> Shahar.
> 

Reply via email to