On 2003/12/13, at 11:12, Rasmus Lerdorf wrote:


On Sat, 13 Dec 2003, Moriyoshi Koizumi wrote:
Overloading is evil, because functions like substr() are often
used to splice a certain length of octets byte-wise while mb_substr()
treats the sequence of octets on a character-basis.

I don't know about this happening often. In singlebyte apps I don't see
this happening often. People splice on character boundaries. Perhaps in
multibyte apps people are using substr this way, but that would seem to be
an incorrect usage of the function. People who do this are taking
advantage of a side-effect of a function designed for a different
character set. substr as documented works on characters, not octets.

"Often" was slightly too emphasized a word indeed, but you can see a typical example on the PEAR package Net_DNS. No matter how substr() or its family are documented, it is very likely abused in many places on a common error that every character is mapped to a single byte.

Moriyoshi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to