-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve encoding while copy and pasting in maintable #5048
Conversation
} | ||
} | ||
try { | ||
return parser.parseEntries(new ByteArrayInputStream(entries.getBytes(StandardCharsets.UTF_8))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Stefan,
Nice to see some commits from you ;-)
I'm not sure whether this is not breaking then the parsing from Strings in other encodings... Have you Hi checked it with some ISO encoded special characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISO special characters should be mappable in UTF-8, right?! I guess currently the default encoding for copying to the clipboard is UTF-8, so pasting with UTF-8 made sense to me. If we want to preserve the real encoding, we probably need to pass the encoding with the DataFlavor somehow? Like https://stackoverflow.com/questions/29651301/text-copied-from-jtextarea-have-broken-encoding-after-paste-in-foxpro-applicatio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always use UTF-8 internally, so this makes indeed sense. Only use case: What if the users has selected a different encoding for the database in the prefs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to preserve the real encoding, we probably need to pass the encoding with the DataFlavor somehow? Like https://stackoverflow.com/questions/29651301/text-copied-from-jtextarea-have-broken-encoding-after-paste-in-foxpro-applicatio
I guess we need to do something like this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is old swing stuff, don't do this.
It should be sufficient to use the encoding in this method and apply the same encoding when pasting.
jabref/src/main/java/org/jabref/gui/ClipBoardManager.java
Lines 83 to 89 in eb42850
public void setContent(List<BibEntry> entries) throws IOException { | |
final ClipboardContent content = new ClipboardContent(); | |
BibEntryWriter writer = new BibEntryWriter(new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false); | |
String serializedEntries = writer.serializeAll(entries, BibDatabaseMode.BIBTEX); | |
content.put(DragAndDropDataFormats.ENTRIES, serializedEntries); | |
content.putString(serializedEntries); | |
clipboard.setContent(content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot spot any place during serialization where we use an encoding different to the default encoding which seems to be UTF-8 then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't we need to pay attention to the database encoding since this option only controls the encoding when the database is written to the file (and does not affect the entries in itself).
It may be worth a try to use parser.parseEntries(new StringReader(entries))
which would circumvent the need to specify an encoding. But whether this works depends on if the JavaFX clipboard is able to correctly encode/decode the string (I tried to dig into the javafx code but it seems that they let the os handle the encoding). Otherwise your solution looks good to me.
Merging this now! |
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (#5040) 58d65fd Create cureus.csl (#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (#5041) 39a3fbb Create finance-and-society.csl (#5043) cf39e19 Create canadian-biosystems-engineering-journal (#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (#5024) 776002d create new independent style for deutsches-arzteblatt.csl (#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (#5036) 13e0a0b Update iso690-full-note-cs.csl (#5033) 3af2034 Create acta-medica-peruana.csl (#5037) dcbe494 Create historia-scribere.csl (#5038) 2174323 make addiction-biology.csl an AMA dependent (#5028) b01aea8 Update ios-press-books.csl (#5030) ae6d0e2 add doi for article-journal for ASA.csl (#5031) d537025 Create organised-sound.csl (#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (#5026) 3dc5157 Update amerindia.csl (#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
6fab78b Create physiologia-plantarum.csl (JabRef#5040) 58d65fd Create cureus.csl (JabRef#5048) 5b68591 Create institut-de-recherches-archeologiques-preventives.csl (JabRef#5042) e238ca2 Create method-and-theory-in-the-study-of-religion.csl (JabRef#5041) 39a3fbb Create finance-and-society.csl (JabRef#5043) cf39e19 Create canadian-biosystems-engineering-journal (JabRef#5046) 3d12b8f Create cardiff-university-biosi-and-carbs-only-harvard.csl (JabRef#5024) 776002d create new independent style for deutsches-arzteblatt.csl (JabRef#5035) b167cd6 Create revista-peruana-de-medicina-experimental-y-salud-publica.csl (JabRef#5036) 13e0a0b Update iso690-full-note-cs.csl (JabRef#5033) 3af2034 Create acta-medica-peruana.csl (JabRef#5037) dcbe494 Create historia-scribere.csl (JabRef#5038) 2174323 make addiction-biology.csl an AMA dependent (JabRef#5028) b01aea8 Update ios-press-books.csl (JabRef#5030) ae6d0e2 add doi for article-journal for ASA.csl (JabRef#5031) d537025 Create organised-sound.csl (JabRef#5032) ef4d15e Create independent EMBO Press 640fdac Create forensic-anthropology.csl (JabRef#5026) 3dc5157 Update amerindia.csl (JabRef#5027) fca38a2 Create journal-of-the-botanical-research-institute-of-texas.csl (JabRef#5029) facc3f9 Aging &Disease: remove unused macros 661e9fa Sort aging and disease by cite number 8746709 show issue numbers in springer basic author-date style (JabRef#4854) c358b17 Update Journal of Universal Computer Science git-subtree-dir: src/main/resources/csl-styles git-subtree-split: 6fab78b
Fixes #5043.
Encodes and decodes data with UTF-8.