Bug 66479 - Copy refactoring should use container encoding to create new file
Summary: Copy refactoring should use container encoding to create new file
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P2 major (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-10 06:18 EDT by Tom Hofmann CLA
Modified: 2004-06-21 04:57 EDT (History)
0 users

See Also:


Attachments
Patch that fixes the problem (14.06 KB, patch)
2004-06-15 19:40 EDT, Dirk Baeumer CLA
no flags Details | Diff
Improved patch after review with Andre (13.15 KB, patch)
2004-06-16 17:14 EDT, Dirk Baeumer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2004-06-10 06:18:48 EDT
I200406091200

- Platform encoding: ISO-8859-1
- Have a folder with UTF-8 encoding
- Create a java class containing some double-byte characters, e.g. �הצ - any non
ASCII will do
- Save
- Select the java file in the package explorer, and drag-copy (hold Ctrl) it
within the same folder
- Accept the proposed class name in the popup
- Open the new class

Observe, depending on the original file
- The multi-byte characters have been replaced with '?'s
- The file cannot be opened because it is not readable using UTF-8

Examining the file shows that it was created using the platform encoding.
Acceptable would be either the encoding of the original file, or the encoding of
the container (folder in this case).
Comment 1 Dirk Baeumer CLA 2004-06-14 13:17:29 EDT
The actual copy is created by the change "CreateCopyOfCompilationUnitChange". 
Have to check what the change does with encodings.
Comment 2 Dirk Baeumer CLA 2004-06-15 10:39:27 EDT
The change has two constructors one defaulting to the workspace encoding one 
having an encoding as an argument. CreateCopyOfCompilationUnitChange using the 
constructor defaulting to the workspace encoding.
Comment 3 Dirk Baeumer CLA 2004-06-15 19:40:35 EDT
Fix isn't as easy as I thought at the beginning. The problem is that if the 
original file inherits the encoding the copied file should inherit the 
encoding as well. 

Fix is middle risk and must be reviewed by an encoding expert (best Andre).
Comment 4 Dirk Baeumer CLA 2004-06-15 19:40:59 EDT
Created attachment 12204 [details]
Patch that fixes the problem
Comment 5 Erich Gamma CLA 2004-06-16 05:47:50 EDT
+1 dirk & erich - the user can loose data.

need to check whether the navigator's copy exposes the same problem.

Comment 6 Dirk Baeumer CLA 2004-06-16 17:14:14 EDT
Created attachment 12335 [details]
Improved patch after review with Andre
Comment 7 Dirk Baeumer CLA 2004-06-17 10:01:00 EDT
Fix release for RC2. Verified by Andre Weinand.
Comment 8 Tom Hofmann CLA 2004-06-21 04:38:55 EDT
verifying...
Comment 9 Tom Hofmann CLA 2004-06-21 04:57:32 EDT
verified that the encoding of the original file is copied
- if the original's encoding it was explicitely set, the new file's is set as well
- if the original's encoding was inherited, the copy's encoding is inherited as
well.