List Info

Thread: removeAccents function proposition




removeAccents function proposition
user name
2007-07-16 11:16:48
Hello all.
I use websvn to publish the sources of my project.

I use a LAMP server, and php error reporting is configured
with E_NOTICES and
E_STRICT.

function removeAccents($string)
{
   return strtr($string,
               
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ&
quot;,
               
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn&
quot;);
}

May be this function ca be replaced with something like that
:
--------

function removeAccents($string)
{
  $string = htmlentities($fileName, ENT_QUOTES,
'ISO-8859-1')) ; // any charset you want here...

  $string =
preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|
slash|tilde|caron);/','$1',$string) ;
  $string =
preg_replace('/&([A-Z])(acute|uml|circ|grave|ring|cedil|
slash|tilde|caron);/','$1',$string) ;

  /* etc... */

  return $string ;
}
--------
Can be optimized with additional tests, of course...
A ful example is available here :
http://www.bildo-project.org/websv
n/filedetails.php?path=%2Ftrunk%2Fdiskio.php
And the function is *CleanFileName*

Thanks,
Andre Rodier


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribewebsvn.tigris.org
For additional commands, e-mail: dev-helpwebsvn.tigris.org


Re: removeAccents function proposition
user name
2007-08-07 09:35:28
On Monday 16 July 2007, andre wrote:
> Hello all.
> I use websvn to publish the sources of my project.
>
> I use a LAMP server, and php error reporting is
configured with
> E_NOTICES and E_STRICT.
>
I do that too.  Did you get a notice or something?

> function removeAccents($string)
> {
>    return strtr($string,
>                
>
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ&
quot;,
>
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn&
quot;); }
>
> May be this function ca be replaced with something like
that :
> --------
>
> function removeAccents($string)
> {
>   $string = htmlentities($fileName, ENT_QUOTES,
'ISO-8859-1')) ; //
> any charset you want here...
>
>   $string =
>
preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|
slash|tilde|c
>aron);/','$1',$string) ; $string =
>
preg_replace('/&([A-Z])(acute|uml|circ|grave|ring|cedil|
slash|tilde|c
>aron);/','$1',$string) ;
>
>   /* etc... */
>
>   return $string ;
> }
> --------
> Can be optimized with additional tests, of course...
> A ful example is available here :
> http://www.bildo-project.org/websvn/filedet
ails.php?path=%2Ftrunk%2Fd
>iskio.php And the function is *CleanFileName*
>
Well, that actually looks like a good idea.  At first I was
wondering 
why you were using a regex to do something that could be
done in a 
look-up table or something like that (not sure on the exact
name for 
it), but then I saw the [A-Z] part.

I'm not entirely sure on the point of the removeAccents()
function, 
however.
> Thanks,
> Andre Rodier
>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribewebsvn.tigris.org
> For additional commands, e-mail: dev-helpwebsvn.tigris.org



-- 
Matt Sicker
Re: removeAccents function proposition
user name
2007-08-13 02:52:31
Hi,

Thanks, I've included your imprioved function.

Matt - the functions there to allow searching without having to take accents into account.

Tim


On 07/08/07, Matt Sicker < boardsgmail.com">boardsgmail.com> wrote:
On Monday 16 July 2007, andre wrote:
>; Hello all.
> I use websvn to publish the sources of my project.
&gt;
> I use a LAMP server, and php error reporting is configured with
> E_NOTICES and E_STRICT.
>
I do that too.  Did you get a notice or something?

> function removeAccents($string)
> {
>&nbsp; &nbsp; return strtr($string,
>
&gt; "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
> "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"); }
>
>; May be this function ca be replaced with something like that :
> --------
&gt;
> function removeAccents($string)
> {
>&nbsp;  $string = htmlentities($fileName, ENT_QUOTES, 'ISO-8859-1')) ; //
> any charset you want here...
&gt;
>&nbsp;  $string =
> preg_replace('/&amp;([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|c
>aron);/',&#39;$1',$string) ; $string =
> preg_replace('/&amp;([A-Z])(acute|uml|circ|grave|ring|cedil|slash|tilde|c
>aron);/',9;$1',$string) ;
>
>; &nbsp; /* etc... */
>
> &nbsp; return $string ;
> }
> --------
&gt; Can be optimized with additional tests, of course...
> A ful example is available here :
> http://www.bildo-project.org/websvn/filedetails.php?path=%2Ftrunk%2Fd
>;iskio.php And the function is *CleanFileName*
>
Well, that actually looks like a good idea. ; At first I was wondering
why you were using a regex to do something that could be done in a
look-up table or something like that (not sure on the exact name for
it), but then I saw the [A-Z] part.

I&#39;m not entirely sure on the point of the removeAccents() function,
however.
&gt; Thanks,
> Andre Rodier
>;
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribewebsvn.tigris.org">dev-unsubscribewebsvn.tigris.org
> For additional commands, e-mail: dev-helpwebsvn.tigris.org">dev-helpwebsvn.tigris.org



--
Matt Sicker




--
http://www.timothyarmes.com
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )