Bug 578332 - Make all supported character sets available for selection
Summary: Make all supported character sets available for selection
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.23   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-22 20:56 EST by Tobias Schmidt CLA
Modified: 2022-01-28 10:49 EST (History)
1 user (show)

See Also:


Attachments
eclipse - Text file encoding (4.67 KB, image/png)
2022-01-22 20:56 EST, Tobias Schmidt CLA
no flags Details
eclipse - Proposed "Text file encoding" combo box (11.20 KB, image/png)
2022-01-22 21:25 EST, Tobias Schmidt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schmidt CLA 2022-01-22 20:56:42 EST
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
Comment 1 Tobias Schmidt CLA 2022-01-22 21:25:28 EST
Created attachment 287879 [details]
eclipse - Proposed "Text file encoding" combo box

I also added an image of a possible solution.
Comment 2 Andrey Loskutov CLA 2022-01-28 10:49:02 EST
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));
 	}