|
List Info
Thread: removeAccents function proposition
|
|
| removeAccents function proposition |

|
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-unsubscribe websvn.tigris.org
For additional commands, e-mail: dev-help websvn.tigris.org
|
|
| Re: removeAccents function proposition |

|
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-unsubscribe websvn.tigris.org
> For additional commands, e-mail: dev-help websvn.tigris.org
--
Matt Sicker
|
|
| Re: removeAccents function proposition |

|
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 < boards gmail.com">boards gmail.com> wrote:
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, > > "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
> "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"); } > > 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);/',9;$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/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.
I39;m not entirely sure on the point of the removeAccents() function, however. > Thanks,
> Andre Rodier > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe websvn.tigris.org">dev-unsubscribe websvn.tigris.org
> For additional commands, e-mail: dev-help websvn.tigris.org">dev-help websvn.tigris.org
-- Matt Sicker
--
http://www.timothyarmes.com
|
[1-3]
|
|