Community
Participate
Working Groups
Created attachment 287878 [details] eclipse - Text file encoding In Eclipse one can choose from about 6 predefined character sets. (e.g. Window->Preferences->General->Workspace->Text file encoding - also see the attachment) However, Java supports significantly more [1], which can even be used by simply typing them (for example just enter "Cp852"). One can also expand this list using the "org.eclipse.ui.encodings" extension point. I think that's a bit cumbersome though, so I think it would be better if one would just put all available character sets to choose from there. [1] https://docs.oracle.com/en/java/javase/11/intl/supported-encodings.html
Created attachment 287879 [details] eclipse - Proposed "Text file encoding" combo box I also added an image of a possible solution.
Please see ancient discussion on bug 34421 why do we have a fixed list of encodings. At least one point is still valid: by adding all encodings, the combo (at least on Linux) becomes unusable. Note: *if* we will change that, it should go to org.eclipse.ui.WorkbenchEncoding.getDefinedEncodings(), something like this: diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/WorkbenchEncoding.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/WorkbenchEncoding.java index d1e38f0..9940633 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/WorkbenchEncoding.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/WorkbenchEncoding.java @@ -20,2 +20,5 @@ import java.util.List; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; import org.eclipse.core.runtime.IConfigurationElement; @@ -101,4 +104,7 @@ } - - return definedEncodings; + SortedMap<String, Charset> charsets = new TreeMap<>(Charset.availableCharsets()); + Charset dummy = Charset.defaultCharset(); + definedEncodings.forEach(e -> charsets.putIfAbsent(e, dummy)); + Set<String> all = charsets.keySet(); + return Collections.synchronizedList(new ArrayList<>(all)); }