php-i18n Digest 9 Feb 2004 19:46:46 -0000 Issue 215
Topics (messages 666 through 666):
Re: String length
666 by: Moriyoshi Koizumi
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Seems I forgot to CC to the list. Sorry for messing about.
Moriyoshi
From: Moriyoshi Koizumi <[EMAIL PROTECTED]>
To: Hayk Chamyan <[EMAIL PROTECTED]>
Subject: Re: [PHP-I18N] String length
Content-Type: text/plain; charset=US-ASCII; format=flowed
Message-Id: <[EMAIL PROTECTED]>
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
--- End Message ---