Repository: jabref/jabref
Issue: Handling of umlaut while copy and paste of entries

Using `JabRef 5.0-dev--snapshot--2019-05-30--master--ef2ebe165` on Windows 10.

The bib-file is UTF-8 encoded (double checked! with extern editor) and in biblatex style. There are entries with umlauts in the abstract, title, etc.

- On entry has well formated umlauts and they are correctly displayed in JabRef editor and preview window.
- Copy such an entry (Ctrl+C)
- Paste it (Ctrl+V)
- All Umlauts are converted into `�`

Example of such a result (copied from the bib-file)
```
@Misc{Nordhausen2019c,
  author    = {Nordhausen, Thomas and Hirt, Julian},
  title     = {One size does not fit all-systematische Literaturrecherche in Fachdatenbanken. Schritt 6: Entwicklung des Suchstrings},
  date      = {2019},
  language  = {ger},
  doi       = {10.6094/KlinPfleg.5.21},
  abstract  = {In diesem Schritt werden die identifizierten Synonyme und Schlagw�rter entsprechend der Suchkomponenten mithilfe von Booleschen Operatoren miteinander verkn�pft. Diese Verkn�pfung wird als Suchstring bezeichnet und muss f�r jede Datenbank gesondert vorgenommen werden. Bei der Entwicklung ist auch der Einsatz von Wortabstandsoperatoren und/oder Platzhaltern f�r eines oder mehrere Zeichen zu ber�cksichtigen. Neben der Verwendung von Schlagw�rtern stellen die Suchbefehle f�r Suchbegriffe und Synonyme eine M�glichkeit dar, um die Suche einzugrenzen. Bei der Verwendung von Suchbefehlen ist deren Schreibweise (Syntax) in der jeweiligen Fachdatenbank zu beachten.},
  file      = {:1015-2668-1-PB.pdf:PDF},
  groups    = {Review, 2019-06},
  keywords  = {lesen, hirt},
  publisher = {Albert-Ludwigs-Universit�t Freiburg},
  year      = {2019},
}
```

Changed files:
src/main/java/org/jabref/gui/ClipBoardManager.java, src/main/java/org/jabref/gui/maintable/MainTable.java

diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java
index c7c6ce2b9d..26bc331fbb 100644
--- a/src/main/java/org/jabref/gui/ClipBoardManager.java
+++ b/src/main/java/org/jabref/gui/ClipBoardManager.java
@@ -1,6 +1,8 @@
 package org.jabref.gui;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
@@ -28,13 +30,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ClipBoardManager {
-
     public static final DataFormat XML = new DataFormat("application/xml");
-    
+
     private static final Logger LOGGER = LoggerFactory.getLogger(ClipBoardManager.class);
 
     private final Clipboard clipboard;
-
     private final ImportFormatReader importFormatReader;
 
     public ClipBoardManager() {
@@ -63,9 +63,8 @@ public class ClipBoardManager {
         String result = clipboard.getString();
         if (result == null) {
             return "";
-        } else {
-            return result;
         }
+        return result;
     }
 
     public void setHtmlContent(String html) {
@@ -89,40 +88,55 @@ public class ClipBoardManager {
         clipboard.setContent(content);
     }
 
-    public List<BibEntry> extractEntries() {
+    public List<BibEntry> extractData() {
         Object entries = clipboard.getContent(DragAndDropDataFormats.ENTRIES);
 
+        if (entries == null) {
+            return handleStringData(clipboard.getString());
+        }
+        return handleBibTeXData((String) entries);
+    }
+
+    private List<BibEntry> handleBibTeXData(String entries) {
         BibtexParser parser = new BibtexParser(Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
-        if (entries != null) {
-            // We have determined that the clipboard data is a set of entries (serialized as a string).
-            try {
-                return parser.parseEntries((String) entries);
-            } catch (ParseException ex) {
-                LOGGER.error("Could not paste", ex);
-            }
-        } else {
-            String data = clipboard.getString();
-            if (data != null) {
-                try {
-                    // fetch from doi
-                    Optional<DOI> doi = DOI.parse(data);
-                    if (doi.isPresent()) {
-                        LOGGER.info("Found DOI in clipboard");
-                        Optional<BibEntry> entry = new DoiFetcher(Globals.prefs.getImportFormatPreferences()).performSearchById(doi.get().getDOI());
-                        return OptionalUtil.toList(entry);
-                    } else {
-                        try {
-                            UnknownFormatImport unknownFormatImport = importFormatReader.importUnknownFormat(data);
-                            return unknownFormatImport.parserResult.getDatabase().getEntries();
-                        } catch (ImportException e) {
-                            // import failed and result will be empty
-                        }
-                    }
-                } catch (FetcherException ex) {
-                    LOGGER.error("Error while fetching", ex);
-                }
-            }
+        try {
+            return parser.parseEntries(new ByteArrayInputStream(entries.getBytes(StandardCharsets.UTF_8)));
+        } catch (ParseException ex) {
+            LOGGER.error("Could not paste", ex);
+            return Collections.emptyList();
+        }
+    }
+
+    private List<BibEntry> handleStringData(String data) {
+        if (data == null || data.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        Optional<DOI> doi = DOI.parse(data);
+        if (doi.isPresent()) {
+            return fetchByDOI(doi.get());
+        }
+
+        return tryImportFormats(data);
+    }
+
+    private List<BibEntry> tryImportFormats(String data) {
+        try {
+            UnknownFormatImport unknownFormatImport = importFormatReader.importUnknownFormat(data);
+            return unknownFormatImport.parserResult.getDatabase().getEntries();
+        } catch (ImportException ignored) {
+            return Collections.emptyList();
+        }
+    }
+
+    private List<BibEntry> fetchByDOI(DOI doi) {
+        LOGGER.info("Found DOI in clipboard");
+        try {
+            Optional<BibEntry> entry = new DoiFetcher(Globals.prefs.getImportFormatPreferences()).performSearchById(doi.getDOI());
+            return OptionalUtil.toList(entry);
+        } catch (FetcherException ex) {
+            LOGGER.error("Error while fetching", ex);
+            return Collections.emptyList();
         }
-        return Collections.emptyList();
     }
 }
diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java
index 892116fb33..6232d33a96 100644
--- a/src/main/java/org/jabref/gui/maintable/MainTable.java
+++ b/src/main/java/org/jabref/gui/maintable/MainTable.java
@@ -209,7 +209,7 @@ public class MainTable extends TableView<BibEntryTableViewModel> {
 
     public void paste() {
         // Find entries in clipboard
-        List<BibEntry> entriesToAdd = Globals.clipboardManager.extractEntries();
+        List<BibEntry> entriesToAdd = Globals.clipboardManager.extractData();
 
         if (!entriesToAdd.isEmpty()) {
             // Add new entries