-
-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
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.