Reply to Re: binary string length

Your name:

Reply:


Posted by Darko on 05/28/07 16:29

On May 28, 6:02 pm, "farri...@gmail.com" <farri...@gmail.com> wrote:
> On May 28, 10:40 am, gezerpunta <css...@gmail.com> wrote:
>
> > Hi
>
> > strlen does not return the correct value .I compared the filesize()
> > and strlen byte size but they are not equal. I must find binary string
> > length and it must be equal to filesize()
>
> > thks.
>
> http://us.php.net/manual/en/function.mb-strlen.php#72979
>
> Google searches ("php binary string length") come in handy...

In PHP, like in C, the string ends with a zero-character, '\0', (char)
0, null-terminator, null-byte or whatever you like to call it. Thus,
if you have binary strings, they probably have this character
somewhere inside them, although that doesn't mean it's the end of the
string. From this reason, it's not very smart to use ordinary
strlen(), and str* functions in general, for binary data. Use, as
farrishj suggested, mb-strlen (multibyte string), or use filesize()
directly, as Ortega suggested. You can, however, make your own
functions to take care of this, just remember the number of bytes you
read together with the data - this, of course, if aforementioned
functions are not good enough for you.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация