sanity fixes about the encodingY
authorJean-Philippe Orsini <orsinije@fr.ibm.com>
Mon, 16 Oct 2017 15:16:06 +0000 (17:16 +0200)
committerJean-Philippe Orsini <orsinije@fr.ibm.com>
Mon, 16 Oct 2017 15:16:06 +0000 (17:16 +0200)
war/src/main/java/pnews/Category.java
war/src/main/java/pnews/servlet/ArticleProvider.java
war/src/main/java/pnews/servlet/Pnews.java

index 7a8106f..2d50c06 100644 (file)
@@ -5,6 +5,7 @@ public enum Category {
         FRANCE("france"),
         SPORT("sport"),
         EUROPE("europe"),
+        MONDE("monde"),
         ECO("eco"),
         ESSONNE("essonne"),
         TECHNOLOGIE("technologie"),
index 9095526..aae0c87 100644 (file)
@@ -18,13 +18,13 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.jsoup.Jsoup;
-import org.xml.sax.InputSource;
 
 import com.rometools.rome.feed.synd.SyndEnclosure;
 import com.rometools.rome.feed.synd.SyndEntry;
 import com.rometools.rome.feed.synd.SyndFeed;
 import com.rometools.rome.io.FeedException;
 import com.rometools.rome.io.SyndFeedInput;
+import com.rometools.rome.io.XmlReader;
 
 import pnews.Article;
 import pnews.Category;
@@ -41,10 +41,13 @@ public class ArticleProvider {
         }
         
         private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
-                InputStream is = new URL(u).openConnection().getInputStream();
-                InputSource source = new InputSource(is);
-                                
-                return new SyndFeedInput().build(source);
+                InputStream is;
+                XmlReader r;
+                
+                r = new XmlReader(new URL(u));
+                XmlReader.setDefaultEncoding("UTF-8");
+                
+                return new SyndFeedInput().build(r);
                 
         }
         
@@ -56,7 +59,6 @@ public class ArticleProvider {
                 result.put(Category.TOP,
                            new String[] {
                                            "http://www.francetvinfo.fr/titres.rss",
-                                           "http://www.france24.com/fr/actualites/rss",                                           
                                            "http://www.rfi.fr/general/rss",
                                            "http://www.cnews.fr/rss/une",
                                            "http://www.ladepeche.fr/rss/a-la-une.rss",
@@ -74,6 +76,10 @@ public class ArticleProvider {
                 
                 result.put(Category.EUROPE,
                                 new String[] { "http://www.france24.com/fr/europe/rss" });
+
+                result.put(Category.MONDE, 
+                           new String[] { "http://www.france24.com/fr/actualites/rss" });                                           
+
                 
                 result.put(Category.ECO,
                                 new String[] { "http://www.france24.com/fr/economie/rss",
@@ -121,7 +127,7 @@ public class ArticleProvider {
                         }
                         if (thumbnail == null)
                                 thumbnail = feedImage;
-                                
+                                                        
                         title = entry.getTitle().trim();
                         
                         if (entry.getDescription() != null) {                                      
index 662b47c..8a98571 100644 (file)
@@ -89,6 +89,7 @@ public class Pnews extends HttpServlet {
                                 html = HTML.toHTML(articles, cat);
                                 rp.setContentType("text/html");
                                 rp.getWriter().write(html);
+                                rp.setCharacterEncoding("UTF-8");
                         } else {
                                 LOG.severe("writeArticles cannot retrieve any articles");
                                 html = HTML.toHTML(new ArrayList<Article>(), cat);