Fwd: [PHP-I18N] String length
| From: | Moriyoshi Koizumi | Date: | Mon, 09 Feb 2004 19:46:21 +0000 |
| Subject: | Fwd: [PHP-I18N] String length | ||
| Groups: | php.i18n | ||
| Request: | Send a blank email to php-i18n+get-666@lists.php.net to get a copy of this message | ||
Seems I forgot to CC to the list. Sorry for messing about.
Moriyoshi
From: Moriyoshi Koizumi <moriyoshi@at.wakwak.com> To: Hayk Chamyan <hayk@softerra.com> Subject: Re: [PHP-I18N] String length Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <A0E5E5E8-5B37-11D8-94B5-000A95CE0C62@at.wakwak.com> Hi, On 2004/02/05, at 18:19, Hayk Chamyan wrote:Hi All. I've got a question regarding the length of binary strings in MB String. Now strlen(file_get_contents('file.bin')) returns string length in bytes. However, if in php.ini we overload the mb_strlen function in place of strlen, specifying mbstring.internal_encoding='UTF8', the result will be wrong. In this regard the question is whether or not a function like mb_strleninbytes expected to return the string lenght in bytes is going to be introduced? Or, do you plan to use mb_strlen($str, ASCII) everywhere instead?You can use mb_orig_strlen() where the byte-wise behaviour is needed, when strlen() is overloaded by mb_strlen(). The same applies to other mbstring counterparts (e.g. substr() - mb_substr() - mb_orig_substr()). This is an undocumented feature though. BTW, while it's found useful sometimes, it's also discouraged to use function overloading as strlen() is the only reasonable way to retrieve the length of a binary object in bytes at this time. I couldn't assure this, but sizeof() / count() will likely replace that functionality of strlen() and strlen() will probably be used solely to get the actual character count. Moriyoshi