From 9be7101759ec8413ead6ab8e7326546648fc15b6 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 22 Sep 2009 20:56:43 +0000 Subject: [PATCH] * fixed encoding problem, added unit test --- source/net/sourceforge/filebot/web/WebRequest.java | 4 ++-- .../net/sourceforge/filebot/web/AnidbClientTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/net/sourceforge/filebot/web/WebRequest.java b/source/net/sourceforge/filebot/web/WebRequest.java index e901c025..5ee0e488 100644 --- a/source/net/sourceforge/filebot/web/WebRequest.java +++ b/source/net/sourceforge/filebot/web/WebRequest.java @@ -145,8 +145,8 @@ public final class WebRequest { } } - // use http default encoding if charset cannot be determined - return Charset.forName("ISO-8859-1"); + // use http default encoding only for text/html, use UTF-8 for everything else (e.g. XML) + return Charset.forName(contentType.equals("text/html") ? "ISO-8859-1" : "UTF-8"); } diff --git a/test/net/sourceforge/filebot/web/AnidbClientTest.java b/test/net/sourceforge/filebot/web/AnidbClientTest.java index e0876a1a..2032f59c 100644 --- a/test/net/sourceforge/filebot/web/AnidbClientTest.java +++ b/test/net/sourceforge/filebot/web/AnidbClientTest.java @@ -24,11 +24,17 @@ public class AnidbClientTest { */ private static HyperLink twelvekingdomsSearchResult; + /** + * 38 episodes, lots of special characters + */ + private static HyperLink princessTutuSearchResult; + @BeforeClass public static void setUpBeforeClass() throws Exception { monsterSearchResult = new HyperLink("Monster", new URL("http://anidb.net/perl-bin/animedb.pl?show=anime&aid=1539")); twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26")); + princessTutuSearchResult = new HyperLink("Princess Tutu", new URL("http://anidb.net/a516")); } @@ -125,6 +131,12 @@ public class AnidbClientTest { } + @Test + public void getEpisodeListEncoding() throws Exception { + assertEquals("Raven Princess - An der schönen blauen Donau", anidb.getEpisodeList(princessTutuSearchResult).get(6).getTitle()); + } + + @Test public void getEpisodeListTrimRecap() throws Exception { assertEquals("Sea God of the East, Azure Sea of the West - Transition Chapter", anidb.getEpisodeList(twelvekingdomsSearchResult).get(44).getTitle());