mb_strtoupper () Does not work On server

0

I have a code that generates some reports in excel, I use mb_strtoupper () to capitalize the results, localhost works with all the letters, but in the server only places the normals, ie the ñ, and tildes does not apply to put them in uppercase, I have to activate something on the server ?, Is the version of php? Is there something that solves it? thanks.

EXAMPLE muñoz word:

Local server

 mb_strtoupper($resulSet['primer_apellido']);
Resultado: MUÑOZ

Hosting server

 mb_strtoupper($resulSet['primer_apellido']);
Resultado: MUñOZ
    
asked by Andress Blend 30.03.2017 в 19:02
source

1 answer

1

The mb_strtoupper function supports a second parameter in which you can specify the encoding. If this second parameter is omitted, the encoding value that the server has by default will be used.

If you indicate UTF-8 should work:

$string=$resulSet['primer_apellido'];
echo mb_strtoupper($string, 'UTF-8'); 

Encryption on the server

To establish / obtain the internal character encoding of the server in PHP, there is a function mb_internal_encoding

Example:

<?php
/* Establecer la codificación de caracteres interna a UTF-8 */
mb_internal_encoding("UTF-8");

/* Mostrar la codificación de caracteres interna en uso */
echo mb_internal_encoding();
?>

Another alternative: CSS

It can also be done by CSS, using text-transform: uppercase :

$string=$resulSet['primer_apellido'];
echo '<span style="text-transform: uppercase;">'. $string. '</span>'; 

Some examples with CSS:

.mayusculas 
{
   text-transform: uppercase;
}
<p>Ejemplo, aplicando directamente el estilo (no recomendado):</p>
<p>muñoz - > <span style="text-transform: uppercase;">muñoz</span> esto no lo quiero en mayúsculas</p>
<p>áéíóú - > <span style="text-transform: uppercase;">áéíóú</span> esto tampoco...</p>
<hr />
<p>Ejemplo usando <strong>buenas prácticas (con nombres de clases)</strong>:</p>
<p>muñoz - > <span class="mayusculas">muñoz</span> esto no lo quiero en mayúsculas</p>
<p>áéíóú - > <span class="mayusculas">áéíóú</span> esto tampoco...</p>
    
answered by 30.03.2017 / 19:22
source