Re: Re[2]: [PHP-ES] Pasar a mayúscula texto con acentos
| From: | Àngel Fenoy | Date: | Wed, 13 Nov 2002 18:44:59 +0000 |
| Subject: | Re: Re[2]: [PHP-ES] Pasar a mayúscula texto con acentos | ||
| References: | 1 2 3 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-29204@lists.php.net to get a copy of this message | ||
Dimecres Novembre 13 2002 10:20, Killer Dog dixit:
> Usad la función STRTR -->
> http://www.php.net/manual/en/function.strtr.php
>
> Yo me he creado una función llamada Mayus que me pasa a mayúsculas y
> además sustituye esos casos particulares...
>
> function Mayus($variable) {
> $variable =
>
> strtr(strtoupper($variable),"àèìòùáéíóúçñäëïöü","ÀÈÌÒÙÁÉÍÓÚÇÑÄËÏÖÜ");
> return $variable;
> }
También yo uso una función similar al Mayus() que nos muestra Killer Dog. Solo
quiero apuntar que PHP puede resolver el problema nativamente, sin necesidad
de funciones nuestras. Si tenemos definida la categoria LC_CTYPE de los
'locale' con el valor de algún lenguaje occidental, podemos usar strtoupper()
para convertir las cadenas. Un ejemplo:
<?
setlocale(LC_CTYPE, 'C');
echo strtoupper('àngel<br>');
setlocale(LC_CTYPE, 'es');
echo strtoupper('àngel');
?>
Resultado:
àNGEL
ÀNGEL
Para más info:
http://www.php.net/manual/en/function.setlocale.php
Saludos
Àngel