From f04a26e081a3eb02b2b9df5be59cbaaf7beff340 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Sat, 24 Aug 2019 14:09:33 +0200 Subject: [PATCH 1/2] fix: use UTF-8 as default encoding for files ~ resolves #5133 If we create journal abbrev files via the JabRef, they are saved in UTF-8. So it makes sense to use this as default encoding. Also see https://github.com/JabRef/jabref/issues/5133. --- .../java/org/jabref/logic/journals/AbbreviationParser.java | 4 ++-- .../org/jabref/logic/journals/JournalAbbreviationLoader.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java index 77d0483027f..282e590d3c9 100644 --- a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java +++ b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; @@ -39,7 +38,8 @@ public void readJournalListFromResource(String resourceFileName) { } public void readJournalListFromFile(File file) throws FileNotFoundException { - try (FileReader reader = new FileReader(Objects.requireNonNull(file))) { + try (FileInputStream stream = new FileInputStream(Objects.requireNonNull(file)); + InputStreamReader reader = new InputStreamReader(stream, Objects.requireNonNull(StandardCharsets.UTF_8))) { readJournalList(reader); } catch (FileNotFoundException e) { throw e; diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java index f1cde1f65b2..fce5ccc2b58 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java @@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory; public class JournalAbbreviationLoader { - private static final Logger LOGGER = LoggerFactory.getLogger(JournalAbbreviationLoader.class); // journal initialization From 19f0d85a132b01ab109879c1f5db4c52496b6d8d Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Sat, 24 Aug 2019 14:38:51 +0200 Subject: [PATCH 2/2] fix: missing separator for unchanged diff words Co-authored-by: Linus Dietz --- src/main/java/org/jabref/gui/mergeentries/DiffHighlighting.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/DiffHighlighting.java b/src/main/java/org/jabref/gui/mergeentries/DiffHighlighting.java index acffbc7acc0..4b93edbb8c8 100644 --- a/src/main/java/org/jabref/gui/mergeentries/DiffHighlighting.java +++ b/src/main/java/org/jabref/gui/mergeentries/DiffHighlighting.java @@ -22,7 +22,7 @@ private DiffHighlighting() { public static List generateDiffHighlighting(String baseString, String modifiedString, String separator) { List stringList = Arrays.asList(baseString.split(separator)); - List result = stringList.stream().map(DiffHighlighting::forUnchanged).collect(Collectors.toList()); + List result = stringList.stream().map(text -> forUnchanged(text + separator)).collect(Collectors.toList()); List> deltaList; try { deltaList = DiffUtils.diff(stringList, Arrays.asList(modifiedString.split(separator))).getDeltas();