Problem decoding chain towards UTF-8

1

I have the following string on an XML file:

seg��n

which is obtained by uploading a file, the thing is that I can not return it to any known character, to say it to ISO-8859-1 or UTF-8 for example

según

or

según

the mb_detect_encoding tells me it's a utf-8

the code is as follows

fwrite($file,
            '<?xml version="1.0" encoding="UTF-8"?>'.
            // utf8_decode(
                mb_convert_encoding(
                html_entity_decode(trim($contenido))
                , 'UTF-8', 'HTML-ENTITIES')
                // )
            );
        fclose($file);

where $contenido is the xml containing that string

    
asked by Hammerffall BK 03.01.2017 в 19:29
source

2 answers

0

Have you tried this?

string utf8_encode (string $ data)

link

    
answered by 03.01.2017 в 19:35
0

use mb_convert_encoding () , example:

$valor_decodificado = mb_convert_encoding($valor_codificado ,'HTML-ENTITIES','utf-8');

or utf8_encode() , example:

$valor_decodificado = utf8_encode($valor_codificado);

Reviewing the html codes of the string that you mention are apparently wrong, both &#56319; as &#56320;

seg&#56319;&#56320;n

should be only &#250;

 seg&#250;n 

so that when decoding the word is shown correctly:

  

according to

    
answered by 03.01.2017 в 19:47