From: Niki Roo Date: Fri, 17 Feb 2017 12:46:38 +0000 (+0100) Subject: Fix UTF-8 and "/" -> "\" issues for Win32 X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=3d247bc3bb955a9b85686f0db431157cb9dc4a10;p=fanfix-jexer.git Fix UTF-8 and "/" -> "\" issues for Win32 It works on Windows now --- diff --git a/VERSION b/VERSION index a602fc9..b0bb878 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.4 +0.9.5 diff --git a/libs/nikiroo-utils-0.9.7-sources.jar b/libs/nikiroo-utils-0.9.8-sources.jar similarity index 71% rename from libs/nikiroo-utils-0.9.7-sources.jar rename to libs/nikiroo-utils-0.9.8-sources.jar index dbccbca..3f930a4 100644 Binary files a/libs/nikiroo-utils-0.9.7-sources.jar and b/libs/nikiroo-utils-0.9.8-sources.jar differ diff --git a/src/be/nikiroo/fanfix/Library.java b/src/be/nikiroo/fanfix/Library.java index b5f246c..a8d9302 100644 --- a/src/be/nikiroo/fanfix/Library.java +++ b/src/be/nikiroo/fanfix/Library.java @@ -136,7 +136,7 @@ public class Library { * @param luid * the Library UID of the story * - * @return the corresponding {@link Story} + * @return the corresponding {@link Story} or NULL if not found */ public Story getStory(String luid) { if (luid != null) { diff --git a/src/be/nikiroo/fanfix/output/Cbz.java b/src/be/nikiroo/fanfix/output/Cbz.java index f618f59..2c9dbc3 100644 --- a/src/be/nikiroo/fanfix/output/Cbz.java +++ b/src/be/nikiroo/fanfix/output/Cbz.java @@ -1,8 +1,10 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; @@ -59,7 +61,8 @@ class Cbz extends BasicOutput { } } - FileWriter writer = new FileWriter(new File(dir, "URL")); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(new File(dir, "URL")), "UTF-8")); try { if (meta != null) { writer.write(meta.getUuid()); @@ -70,7 +73,8 @@ class Cbz extends BasicOutput { writer.close(); } - writer = new FileWriter(new File(dir, "SUMMARY")); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(new File(dir, "SUMMARY")), "UTF-8")); try { String title = ""; if (meta != null && meta.getTitle() != null) { diff --git a/src/be/nikiroo/fanfix/output/Epub.java b/src/be/nikiroo/fanfix/output/Epub.java index f27391b..3e875aa 100644 --- a/src/be/nikiroo/fanfix/output/Epub.java +++ b/src/be/nikiroo/fanfix/output/Epub.java @@ -1,9 +1,11 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStreamWriter; import java.net.URL; import javax.imageio.ImageIO; @@ -14,14 +16,14 @@ import be.nikiroo.fanfix.bundles.StringId; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; -import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.data.Paragraph.ParagraphType; +import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.IOUtils; import be.nikiroo.utils.StringUtils; class Epub extends BasicOutput { private File tmpDir; - private FileWriter writer; + private BufferedWriter writer; private boolean inDialogue = false; private boolean inNormal = false; private File images; @@ -119,7 +121,9 @@ class Epub extends BasicOutput { protected void writeChapterHeader(Chapter chap) throws IOException { String filename = String.format("%s%03d%s", "chapter-", chap.getNumber(), ".xml"); - writer = new FileWriter(new File(tmpDir + "/OPS", filename)); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(new File(tmpDir + File.separator + "OPS", + filename)), "UTF-8")); inDialogue = false; inNormal = false; try { diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java index fcffec6..3ed52ad 100644 --- a/src/be/nikiroo/fanfix/output/Html.java +++ b/src/be/nikiroo/fanfix/output/Html.java @@ -1,9 +1,11 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStreamWriter; import javax.imageio.ImageIO; @@ -19,7 +21,7 @@ import be.nikiroo.utils.StringUtils; class Html extends BasicOutput { private File dir; - protected FileWriter writer; + protected BufferedWriter writer; private boolean inDialogue = false; private boolean inNormal = false; @@ -32,12 +34,12 @@ class Html extends BasicOutput { target.mkdir(); dir = target; - targetName = new File(targetName, "index").getPath(); targetName += getDefaultExtension(); target = new File(targetDir, targetName); - writer = new FileWriter(target); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(target), "UTF-8")); try { super.process(story, targetDir, targetNameOrig); } finally { diff --git a/src/be/nikiroo/fanfix/output/InfoCover.java b/src/be/nikiroo/fanfix/output/InfoCover.java index 74505e7..1a63dce 100644 --- a/src/be/nikiroo/fanfix/output/InfoCover.java +++ b/src/be/nikiroo/fanfix/output/InfoCover.java @@ -1,8 +1,10 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import javax.imageio.ImageIO; @@ -14,7 +16,8 @@ class InfoCover { public static void writeInfo(File targetDir, String targetName, MetaData meta) throws IOException { File info = new File(targetDir, targetName + ".info"); - FileWriter infoWriter = new FileWriter(info); + BufferedWriter infoWriter = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(info), "UTF-8")); if (meta != null) { try { @@ -73,8 +76,8 @@ class InfoCover { } } - private static void writeMeta(FileWriter writer, String key, String value) - throws IOException { + private static void writeMeta(BufferedWriter writer, String key, + String value) throws IOException { if (value == null) { value = ""; } diff --git a/src/be/nikiroo/fanfix/output/LaTeX.java b/src/be/nikiroo/fanfix/output/LaTeX.java index a4ed4d2..d322e4a 100644 --- a/src/be/nikiroo/fanfix/output/LaTeX.java +++ b/src/be/nikiroo/fanfix/output/LaTeX.java @@ -1,19 +1,21 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.bundles.StringId; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; -import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.data.Paragraph.ParagraphType; +import be.nikiroo.fanfix.data.Story; class LaTeX extends BasicOutput { - protected FileWriter writer; + protected BufferedWriter writer; private boolean lastWasQuote = false; // quote chars @@ -34,7 +36,8 @@ class LaTeX extends BasicOutput { File target = new File(targetDir, targetName); - writer = new FileWriter(target); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(target), "UTF-8")); try { super.process(story, targetDir, targetNameOrig); } finally { diff --git a/src/be/nikiroo/fanfix/output/Text.java b/src/be/nikiroo/fanfix/output/Text.java index 4555ce6..4acfa76 100644 --- a/src/be/nikiroo/fanfix/output/Text.java +++ b/src/be/nikiroo/fanfix/output/Text.java @@ -1,8 +1,10 @@ package be.nikiroo.fanfix.output; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import java.net.URL; import be.nikiroo.fanfix.Instance; @@ -10,11 +12,11 @@ import be.nikiroo.fanfix.bundles.StringId; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; -import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.data.Paragraph.ParagraphType; +import be.nikiroo.fanfix.data.Story; class Text extends BasicOutput { - protected FileWriter writer; + protected BufferedWriter writer; protected File targetDir; @Override @@ -27,7 +29,8 @@ class Text extends BasicOutput { File target = new File(targetDir, targetName); - writer = new FileWriter(target); + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(target), "UTF-8")); try { super.process(story, targetDir, targetNameOrig); } finally { diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index bfb8b97..86b779c 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -48,21 +48,23 @@ class LocalReader extends BasicReader { } // return new luid - public String imprt(String luid) { + public String imprt(String luid) throws IOException { try { Story story = Instance.getLibrary().getStory(luid); - story = lib.save(story); - return story.getMeta().getLuid(); + if (story != null) { + story = lib.save(story); + return story.getMeta().getLuid(); + } else { + throw new IOException("Cannot find story in Library: " + luid); + } } catch (IOException e) { - Instance.syserr(new IOException( + throw new IOException( "Cannot import story from library to LocalReader library: " - + luid, e)); + + luid, e); } - - return null; } - public File getTarget(String luid) { + public File getTarget(String luid) throws IOException { MetaData meta = lib.getInfo(luid); File file = lib.getFile(luid); if (file == null) {