From 1718e1e05c26aa7fc4990e41b224ec2494e52552 Mon Sep 17 00:00:00 2001 From: veronie Date: Tue, 16 Feb 2021 16:58:00 +0100 Subject: [PATCH] Fixed encoding in game list. --- .../src/xyz/veronie/bgg/result/BggApi.java | 4 ++-- .../veronie/bgg/ui/handlers/ImportResultTxtHandler.java | 9 +++++++-- .../src/xyz/veronie/bgg/ui/parts/BatMain.java | 1 - 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java index 7b0ceef..1785174 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/BggApi.java @@ -160,8 +160,8 @@ public class BggApi { } else { // HTTP_OK, go on... BufferedReader in = new BufferedReader( - new InputStreamReader(con.getInputStream())); - String inputLine; + new InputStreamReader(con.getInputStream(), "UTF-8")); + String inputLine = new String(); StringBuffer content = new StringBuffer(); while ((inputLine = in.readLine()) != null) { content.append(inputLine); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/ImportResultTxtHandler.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/ImportResultTxtHandler.java index f368864..93843bf 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/ImportResultTxtHandler.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/handlers/ImportResultTxtHandler.java @@ -58,6 +58,7 @@ public class ImportResultTxtHandler { int lineNo = 0; // count overall lines int errNo = 0; // count unparsable lines int dupNo = 0; // count duplicates + boolean header = false; try { input = new FileReader(resultPath); @@ -69,7 +70,10 @@ public class ImportResultTxtHandler { lineNo++; String[] tokens = myLine.split(","); if(tokens.length > 0) { - if(tokens[0].equals("id")) continue; // header line + if(tokens[0].equals("id")) { + header = true; + continue; // header line + } try { boolean exists = !ids.add(Integer.parseInt(tokens[0])); if(exists) { @@ -90,7 +94,8 @@ public class ImportResultTxtHandler { if(ids != null) { MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); StringBuilder msg = new StringBuilder(); - int thingsNo = lineNo - errNo - dupNo - 1; + int thingsNo = lineNo - errNo - dupNo; + if(header) thingsNo -= 1; msg.append("Parsing successful. Found ").append(Integer.toString(thingsNo)).append(" things."); if(errNo > 0) { msg.append("\n\rSkipped ").append(Integer.toString(errNo)).append(" line(s)."); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java index ff8c419..97c8a03 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BatMain.java @@ -30,7 +30,6 @@ import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout;