Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 27679 Details for
Bug 110576
[encoding] Rename CU looses encoding for file which charset is determined by contents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to fix this issue
v00.txt (text/plain), 5.49 KB, created by
Frederic Fusier
on 2005-09-29 11:23:10 EDT
(
hide
)
Description:
Patch to fix this issue
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-09-29 11:23:10 EDT
Size:
5.49 KB
patch
obsolete
>Index: compiler/org/eclipse/jdt/internal/compiler/util/Util.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java,v >retrieving revision 1.49 >diff -u -r1.49 Util.java >--- compiler/org/eclipse/jdt/internal/compiler/util/Util.java 23 May 2005 15:11:35 -0000 1.49 >+++ compiler/org/eclipse/jdt/internal/compiler/util/Util.java 29 Sep 2005 15:19:45 -0000 >@@ -28,6 +28,7 @@ > } > > private static final int DEFAULT_READING_SIZE = 8192; >+ public final static String UTF_8 = "UTF-8"; //$NON-NLS-1$ > public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ > > /** >@@ -219,7 +220,7 @@ > > // Do not keep first character for UTF-8 BOM encoding > int start = 0; >- if (contentsLength > 0 && "UTF-8".equals(encoding)) { //$NON-NLS-1$ >+ if (contentsLength > 0 && UTF_8.equals(encoding)) { //$NON-NLS-1$ > if (contents[0] == 0xFEFF) { // if BOM char then skip > contentsLength--; > start = 1; >@@ -246,7 +247,7 @@ > } > // Do not keep first character for UTF-8 BOM encoding > int start = 0; >- if (length > 0 && "UTF-8".equals(encoding)) { //$NON-NLS-1$ >+ if (length > 0 && UTF_8.equals(encoding)) { //$NON-NLS-1$ > if (contents[0] == 0xFEFF) { // if BOM char then skip > len--; > start = 1; >Index: model/org/eclipse/jdt/internal/core/Buffer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java,v >retrieving revision 1.51 >diff -u -r1.51 Buffer.java >--- model/org/eclipse/jdt/internal/core/Buffer.java 23 Feb 2005 02:47:29 -0000 1.51 >+++ model/org/eclipse/jdt/internal/core/Buffer.java 29 Sep 2005 15:19:46 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.content.IContentDescription; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.internal.core.util.Util; > >@@ -334,6 +335,10 @@ > > // use a platform operation to update the resource contents > try { >+ String stringContents = this.getContents(); >+ if (stringContents == null) return; >+ >+ // Get encoding > String encoding = null; > try { > encoding = this.file.getCharset(); >@@ -341,13 +346,27 @@ > catch (CoreException ce) { > // use no encoding > } >- String stringContents = this.getContents(); >- if (stringContents == null) return; >+ >+ // Create bytes array > byte[] bytes = encoding == null > ? stringContents.getBytes() > : stringContents.getBytes(encoding); >- ByteArrayInputStream stream = new ByteArrayInputStream(bytes); > >+ // Special case for UTF-8 BOM files >+ // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=110576 >+ if (encoding.equals(org.eclipse.jdt.internal.compiler.util.Util.UTF_8)) { //$NON-NLS-1$ >+ IContentDescription description = this.file.getContentDescription(); >+ if (description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null) { >+ int bomLength= IContentDescription.BOM_UTF_8.length; >+ byte[] bytesWithBOM= new byte[bytes.length + bomLength]; >+ System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength); >+ System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length); >+ bytes= bytesWithBOM; >+ } >+ } >+ >+ // Set file contents >+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes); > if (this.file.exists()) { > this.file.setContents( > stream, >Index: model/org/eclipse/jdt/internal/core/JavaProject.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v >retrieving revision 1.347.2.1 >diff -u -r1.347.2.1 JavaProject.java >--- model/org/eclipse/jdt/internal/core/JavaProject.java 5 Sep 2005 11:38:25 -0000 1.347.2.1 >+++ model/org/eclipse/jdt/internal/core/JavaProject.java 29 Sep 2005 15:19:49 -0000 >@@ -2113,7 +2113,7 @@ > if (rscFile.exists()) { > byte[] bytes = Util.getResourceContentsAsByteArray(rscFile); > try { >- property = new String(bytes, "UTF-8"); //$NON-NLS-1$ // .classpath always encoded with UTF-8 >+ property = new String(bytes, org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8 > } catch (UnsupportedEncodingException e) { > Util.log(e, "Could not read .classpath with UTF-8 encoding"); //$NON-NLS-1$ > // fallback to default >@@ -2132,7 +2132,7 @@ > return null; > } > try { >- property = new String(bytes, "UTF-8"); //$NON-NLS-1$ // .classpath always encoded with UTF-8 >+ property = new String(bytes, org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8 > } catch (UnsupportedEncodingException e) { > Util.log(e, "Could not read .classpath with UTF-8 encoding"); //$NON-NLS-1$ > // fallback to default >@@ -2888,7 +2888,7 @@ > IFile rscFile = this.project.getFile(key); > byte[] bytes = null; > try { >- bytes = value.getBytes("UTF-8"); //$NON-NLS-1$ // .classpath always encoded with UTF-8 >+ bytes = value.getBytes(org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8 > } catch (UnsupportedEncodingException e) { > Util.log(e, "Could not write .classpath with UTF-8 encoding "); //$NON-NLS-1$ > // fallback to default
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 110576
: 27679