Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-03-08 18:34:51 +0000
committerKai Maetzel2004-03-08 18:34:51 +0000
commitecbcffd018e5782f4d15df0530e181d26eff2357 (patch)
tree2e819e2ee48388f2ad18323a2cd28ea56e9ecfd1 /org.eclipse.core.filebuffers
parentfb918ffc824c5b75c3bb99370722a356f66e548f (diff)
downloadeclipse.platform.text-ecbcffd018e5782f4d15df0530e181d26eff2357.tar.gz
eclipse.platform.text-ecbcffd018e5782f4d15df0530e181d26eff2357.tar.xz
eclipse.platform.text-ecbcffd018e5782f4d15df0530e181d26eff2357.zip
#54058
Diffstat (limited to 'org.eclipse.core.filebuffers')
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
index b18404c04..9a3535835 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
@@ -111,7 +111,7 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
public void setEncoding(String encoding) {
fEncoding= encoding;
try {
- fFile.setPersistentProperty(ENCODING_KEY, encoding);
+ fFile.setCharset(encoding);
} catch (CoreException x) {
handleCoreException(x);
}
@@ -193,7 +193,25 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
*/
protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException {
try {
- fEncoding= fFile.getPersistentProperty(ENCODING_KEY);
+ fEncoding= null;
+ try {
+ fEncoding= fFile.getPersistentProperty(ENCODING_KEY);
+ } catch (CoreException x) {
+ // we ignore exceptions here because we support the ENCODING_KEY property only for compatibility reasons
+ }
+ if (fEncoding != null) {
+ // if we found an old encoding property, we try to migrate it to the new core.resources encoding support
+ try {
+ fFile.setCharset(fEncoding);
+ // if successful delete old property
+ fFile.setPersistentProperty(ENCODING_KEY, null);
+ } catch (CoreException ex) {
+ // log problem because we could not migrate the property successfully
+ handleCoreException(ex);
+ }
+ } else {
+ fEncoding= fFile.getCharset();
+ }
fDocument= fManager.createEmptyDocument(fFile.getLocation());
setDocumentContent(fDocument, fFile.getContents(), fEncoding);
} catch (CoreException x) {

Back to the top