PHP Classes

Native functionality

Recommend this page to a friend!

      Unicode Manipulation  >  All threads  >  Native functionality  >  (Un) Subscribe thread alerts  
Subject:Native functionality
Summary:mb_string? iconv?
Messages:2
Author:Jase
Date:2010-07-28 13:13:07
Update:2012-07-06 13:06:01
 

  1. Native functionality   Reply   Report abuse  
Picture of Jase Jase - 2010-07-28 13:13:07
Hi

Looking through the class, I can't help but notice that in some cases, either iconv or mb_string functions should be used. They are very easy to check for if they are installed and will deliver significant speed improvements

I've also noticed the reliance on strlen. This is very dangerous when considering that mb_string functions can overload some native string functions like strlen. You should really check to see if strlen is overloaded and if it is, then use mb_strlen(str, '8bit'); (overloading implies the mb functions are available anyways)

Obviously your custom manipulation works great but the strlen issue could be a problem. Maybe build on this current code to make it more robust? In cases that the mb or iconv functions can be used, then use them for significant speed improvements

please be advised that I'm well aware mb and iconv isn't installed on all servers but I'm suggesting them as a first port of call (check if they are installed, if not, your custom functionality would be the fallback) and obviously is mb_strlen isn't installed then strlen should carry on fine.

  2. Re: Native functionality   Reply   Report abuse  
Picture of Rubens Takiguti Ribeiro Rubens Takiguti Ribeiro - 2012-07-06 13:06:01 - In reply to message 1 from Jase
Hi Jase,

Sorry about a reply at this time, but I did not see your post.

I have understood your suggestion, but I did not find where php.net says that mb_strlen can overload native strlen function. Could you post any reference about it?

Thanks