Skip to content
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

Consistent encoding strings #155

Closed
koppor opened this issue Sep 10, 2015 · 8 comments
Closed

Consistent encoding strings #155

koppor opened this issue Sep 10, 2015 · 8 comments

Comments

@koppor
Copy link
Member

koppor commented Sep 10, 2015

JabRef's current encoding list lists possible encodings.

The strings have flaws:

On the one hand, I am very well aware that a change here results in a large compatibility code where the old strings have to be mapped to the new strings. On the other hand, I would like to see JabRef having strings not causing confusion.

Related: #118, #131

@lenhard
Copy link
Member

lenhard commented Sep 17, 2015

I fully agree with what you write and just had a look at this issue.

As far as I can see, we can just replace the faulty names with the correct ones in ALL_ENCODINGS and add the correct names to ENCODING_NAMES_LOOKUP. This means we have two keys (the correct name and the old name) for the same encoding. This should not break anything, since ALL_ENCODINGS is only used to display available encoding names in the UI and ENCODING_NAMES_LOOKUP is used for for actually applying an encoding. Hence, duplicate keys won't hurt as long as the values are ok (which, I assume, they are).

To sum up: This change looks pretty easy to me, but perhaps I just overlooked a difficult problem. Can you point me to code that breaks with the above changes?

@simonharrer
Copy link
Contributor

Can the user select the encoding in the UI? Do we want to automatically upgrade from an old encoding name to the new encoding name? Where are the used encodings stored?

@lenhard
Copy link
Member

lenhard commented Sep 17, 2015

  • Can the user select the encoding in the UI?

Yes, at various positions, for instance when a save action fails with an UnsupportedCharsetException. Example code is:

Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"),
                        JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS, encoding);
  • Do we want to automatically upgrade from an old encoding name to the new encoding name?

Can you describe some more what exactly you mean by automatic upgrade? Me changing source code would be a manual upgrade.

  • Where are the used encodings stored?

Encodings are stored in the Encodings class as linked by Olly above.

@koppor
Copy link
Member Author

koppor commented Sep 17, 2015

  • Do we want to automatically upgrade from an old encoding name to the new encoding name?

Yes! I know that this will introduce backward compatibility issues. However, we should move forward ^^.
(I think Simon meant the encoding string in the .bib file)

@lenhard lenhard changed the title Consistent encoding strings [WIP] Consistent encoding strings Sep 18, 2015
@simonharrer
Copy link
Contributor

👍

Automatic upgrade: replace the encoding in the first line of the .bib file with a newer encoding: utf8 --> utf-8

Are encodings stored in the preferences as well? Do we have to upgrade there, too?

@lenhard
Copy link
Member

lenhard commented Sep 18, 2015

Are encodings stored in the preferences as well? Do we have to upgrade there, too?

I have no idea, but would be very glad if you find out :)

@simonharrer
Copy link
Contributor

JabRefPreferences.DEFAULT_ENCODING can be selected from the list of encodings. Hence, it can contain an old encoding which would need to be migrated to a newer one as well.

@lenhard
Copy link
Member

lenhard commented Sep 18, 2015

The only critical position where encodings were hardcoded were the preferences. Thanks @simonharrer!

I added compatibility code to automatically update the preferences and this issue should be fixed.

@koppor koppor changed the title [WIP] Consistent encoding strings Consistent encoding strings Sep 25, 2015
This was referenced Nov 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants