The problem is that substr does not fully support strings with an utf8 encoding (it counts the multiple bytes as different characters and can thus chop characters in two). PHP does have (in many versions) multi-byte character functions to handle these sort of strings, but they are not enabled by default (and I am not sure if they were generally available when Drupal first started to use utf8). I guess the implementers of Drupal felt is was easier to implement their own version of the functions to be m utf8 aware than to deal with the support issues of telling people how to get these functions enabled on their system. Remember that many people are on shared hosting systems where adding modules into PHP is not trivial, and sometimes requires negotiating with the hosting provider to get them to install it.
On May 8, 2012 at 10:33 AM George Dawson george.dawson@earthlink.net wrote:
Why does Drupal have it's own substr function? I have noticed on my
system, Drupal is too slow, and this would only add to the overhead of processing a very simple command. Is Drupal becoming a language in it's own right?
-----Original Message-----
From: Earnie Boyd earnie@users.sourceforge.net Sent: May 8, 2012 8:25 AM To: support@drupal.org, "Ms. Nancy Wichmann" nan_wich@bellsouth.net Subject: Re: [support] Substr or Drupal_substr?
On Mon, May 7, 2012 at 9:11 PM, Ms. Nancy Wichmann nan_wich@bellsouth.net wrote:
Coder keeps flagging this, so I thought I'd ask about it. Following a parse_url() of a URL input from a form, is the use of drupal_substr()
really
necessary, or is a basic substr() adequate?
What is the coder message? I see nothing about drupal_substr in the http://drupal.org/update/modules/6/7 page. Coder is very imperfect so maybe it is a bug. I opened several issues last month.
-- Earnie
-- https://sites.google.com/site/earnieboyd
[ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]