Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it L'avatar di nourdine
    Registrato dal
    Nov 2005
    Messaggi
    1,130

    feed reader con problemi per caratteri accentati

    ho probelmi con dei caratteri accentati. Ho scritto uno script per la lettura di feed di altri siti con simpleXML e mi scrive dei caratteri in modo folle. per esempio lanciate lo script su qualche server e date un'occhiata al titolo principale di pagina "novità quotidiane ...". La à è tutta incasinata. ecco il codice del feed reader:
    codice:
    <?php
    
    $document = simplexml_load_file("http://rss.html.it/alldaily.xml");
    	foreach($document->channel as $channel){
    		echo "<h1>" . $channel->title . "</h1>\n";
    		echo "<h2>" . $channel->description . "</h2>\n";
    		echo "<h2>Link alla risorsa: " . $channel->link . "</h2>\n";
    		echo "<h2>Ultimo aggiornamento: " . $channel->lastBuildDate . "</h2>\n";
    		echo "[img]" . $channel->image->url . "[/img]\n";
    		echo "<h3>Lista dei contenuti rss</h3>\n";
    		
    		
    			foreach($channel->item as $item){
    			   echo "
    
    Titolo: " . $item->title . "</p>\n"; 
    				echo "
    
    Link: " . $item->link . "</p>\n";
    				echo "
    
    Descrizione: " . htmlentities($item->description) . "</p>\n";
    				echo "
    
    Autore: " . $item->author . "</p>\n";
    				echo "
    
    Data: " . $item->pubDate . "</p>\n";
    				echo "<hr />\n\n";  	
    			}
    		}
    
    ?>

  2. #2

    .............

    Ciao.
    Prova con utf8_encode .

    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente di HTML.it L'avatar di nourdine
    Registrato dal
    Nov 2005
    Messaggi
    1,130
    cambia un cazzo!

  4. #4

    ..........

    La cosa buffa è che togliendo
    htmlentities funziona
    mah alle brutte utilizza str_replace
    passando un array con tutte le
    lettere accentate e relativo
    entità html (ma sembra di riinventare la ruota)
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  5. #5

    ......

    Così funziona htmlentities(utf8_decode($item->description))
    però mi piacerebbe capire perchè

    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  6. #6
    Utente di HTML.it L'avatar di nourdine
    Registrato dal
    Nov 2005
    Messaggi
    1,130
    anke a me! boh! va a capirli te i linguaggi di scripting :-P

  7. #7

    .......

    Una soluzione + pulita da manuale
    Se non c'è intestazione xhtml
    header('Content-Type: text/html; charset=UTF-8');
    e poi semplicissimo (e si batti e ribatti)
    htmlentities($item->description, ENT_COMPAT, 'UTF-8')
    and it works


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.