I'm developing a rss feed for my site. The problem becomes when I trying to decode the content, some characters are not decoded correctly.
This is my string on my row "html" in my table with utf8_spanish2_ci
collation:
I save data with utf8_encode
.
<p style="text-align: center">Calidad: ⦠BRrip<br />Peso: ⦠693 Mb<br />Duración: ⦠1:33:09 Hs.<br />Codec video: ⦠Xvid<br />Formato: ⦠Avi<br />Resolución: ⦠640 x 272<br />Bitrate del video: ⦠904 Kbps<br />Frame rate: ⦠23.976 fps<br />Idioma: ⦠Español Latino<br />Codec Audio: ⦠MP3<br />Bitrate Audio: ⦠128 Kb/s 44100hz<br />Subtitulos: ⦠No Tiene</p>
The string Outputs:
With utf8_decode
, some characters are not decoded correctly
<p style="text-align: center">Calidad: �?� BRrip<br />Peso: �?� 693 Mb<br />Duración: �?� 1:33:09 Hs.<br />Codec video: �?� Xvid<br />Formato: �?� Avi<br />Resolución: �?� 640 x 272<br />Bitrate del video: �?� 904 Kbps<br />Frame rate: �?� 23.976 fps<br />Idioma: �?� Español Latino<br />Codec Audio: �?� MP3<br />Bitrate Audio: �?� 128 Kb/s 44100hz<br />Subtitulos: �?� No Tiene</p>
The string should be:
<p style="text-align: center">Calidad: … BRrip<br />Peso: … 693 Mb<br />Duración: … 1:33:09 Hs.<br />Codec video: … Xvid<br />Formato: … Avi<br />Resolución: … 640 x 272<br />Bitrate del video: … 904 Kbps<br />Frame rate: … 23.976 fps<br />Idioma: … Español Latino<br />Codec Audio: … MP3<br />Bitrate Audio: … 128 Kb/s 44100hz<br />Subtitulos: … No Tiene</p>
This is my complete code:
<?php
header('Content-Type: application/rss+xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo "\n<rss version='2.0'>";
echo "<channel>\n";
echo "<title>Feed Juegos</title>\n";
echo "<link>http://example.com</link>\n";
echo "<description>Ultimas Entradas Xxx Javi</description>\n";
DEFINE ('USER', 'zadmin_new');
DEFINE ('PWW', 'mierda');
DEFINE ('HOST_BD', 'localhost');
DEFINE ('DBNAME', 'zadmin_warezo');
$conexion = mysql_connect(HOST_BD, USER, PWW) or
die ('No se pudo conectar a la BD');
mysql_select_db(DBNAME) or die ('Error in connection');
$query= "SELECT * FROM posts WHERE id_cat = 6 ORDER BY posts.fecha DESC LIMIT 0,18";
$result = mysql_query($query) or die ('ERROR IN QUERY');
while ($fila = mysql_fetch_array($result, MYSQL_ASSOC))
{
$desc = $fila['html'];
echo "<item>\n";
echo "<title>".$fila['titulo']."</title>\n";
echo "<link>http://example.com/peliculas-series/2/".$fila['id']."/".$fila['slug'].".html</link>\n";
echo "<description>
".$desc."
</description>";
echo "</item>\n";
}
echo "</channel>";
echo "</rss>";
?>