Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 47346

Summary: [GlobalActions] [encoding] Convert content when change encoding
Product: [Eclipse Project] Platform Reporter: Csaba Horvath <hcs333>
Component: IDEAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, david_williams, eclipse, markus.kell.r, nobody, raszagar
Version: 3.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug

Description Csaba Horvath CLA 2003-11-24 10:17:32 EST
Eclipse 3.0 build id: I200311211210
Default workbench encoding is set to: Cp1250
If I open a text file containing accented chars (i.e. á) and after open I 
select Edit->Encoding->UTF-8. All characters entered after this operation will 
be saved in the right UTF-8 format but in the original content (that was there 
before the encoding change) all accented characters was encoded to an 'ef bf 
bd' (hexa) sequence.
The editor should support converting of original content if I change the 
encoding of the editor (or notify me about possibly wrong conversion of non us-
ascii characters).
Comment 1 raszagar CLA 2007-02-07 08:02:23 EST
Eclipse Platform
Version: 3.2.0
Build id: M20060921-0945

SO: Windows XP

I test this version in PDT (PHP develoment tool) 0.7 Stable Build: S20070130-RC2, package All-in-One for windows. 

When I open a text file (php) containing accented chars (á,é,...) or tilde (ñ), this characters show wrong.

Example:
   año = a&#65533;o
   mínimo = m&#65533;nimo

Note: if you select Edit->Encoding->ISO-8859-1 this characters show fine, but if you edit text file and forget change enconding option the file will be saved with wrong characters (&#65533;).
Comment 2 Dani Megert CLA 2009-03-25 07:40:23 EDT
The text editor only reacts on the encoding change issued by the org.eclipse.ui.ide.dialogs.ResourceEncodingFieldEditor. If Eclipse decides to always (or optionally via setting) try to convert the file content then this is up to this class. The editor would pick up such a content change.

Moving to Platform UI.

NOTE:
1) doing such a conversion can be dangerous and can result in lost data. See also bug 269314.
2) the new feature would probably have to go into org.eclipse.ui.ide.dialogs.AbstractEncodingFieldEditor as the org.eclipse.ui.ide.dialogs.EncodingFieldEditor is also affected
Comment 3 Markus Keller CLA 2009-03-25 10:12:21 EDT
Note that "Convert Encoding" is different from "Set Encoding", so "Convert Encoding" needs to be a separate operation.

The combo in the the resource properties dialog should *not* change the encoding. The Resource page should only change meta-information about the resource, so it's doing a "Set Encoding" operation.

There should rather be an additional "Convert Encoding" command that converts the encoding of selected files (similar to "File > Convert Line Delimiters To"). The implementation could use the refactoring framework to give the user a preview of the changes and to provide an undo.
Comment 4 Dani Megert CLA 2009-03-25 10:29:03 EDT
>There should rather be an additional "Convert Encoding" command that converts
Yes, either that or a check box on the current dialog as several people already now expect the conversion to happen.
Comment 5 Nobody - feel free to take it CLA 2014-10-16 15:27:15 EDT
http://artur.ejsmont.org/blog/Convertig-file-encoding-to-UTF-8-from-other-Unicode-and-removing-Byte-Order-Marks provides a good workaround for this.
Comment 6 Dani Megert CLA 2015-03-17 09:11:00 EDT
*** Bug 462316 has been marked as a duplicate of this bug. ***
Comment 7 Eclipse Genie CLA 2020-04-07 14:35:17 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.