summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-04-07 10:05:11 (EDT)
committerpelder2006-04-07 10:05:11 (EDT)
commitb318c421da72201e70f8e85302de48a40b3075e4 (patch)
treed61849038bf04649fbe12bbc7ff328648012cabe
parent6c4f144228df2659e2c443c07c9d4e331dc55dea (diff)
downloadorg.eclipse.jet-b318c421da72201e70f8e85302de48a40b3075e4.zip
org.eclipse.jet-b318c421da72201e70f8e85302de48a40b3075e4.tar.gz
org.eclipse.jet-b318c421da72201e70f8e85302de48a40b3075e4.tar.bz2
[134583] Ensure UTF-8 files get a Byte Order Mark (BOM), working around a Sun defect.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
index 11a4d8f..37894c9 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.SequenceInputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.text.MessageFormat;
@@ -39,6 +40,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jet.JET2Writer;
@@ -144,7 +146,13 @@ public final class ActionsUtil
}
// Step 2: convert the contents to a byte stream of the proper type
- ByteArrayInputStream source = new ByteArrayInputStream(contents.getBytes(file.getCharset()));
+ InputStream source = new ByteArrayInputStream(contents.getBytes(file.getCharset()));
+
+ // work around SUN bug with UTF-8 encoding and byte-order marks.
+ // See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
+ if("UTF-8".equals(file.getCharset())) { //$NON-NLS-1$
+ source = new SequenceInputStream(new ByteArrayInputStream(IContentDescription.BOM_UTF_8), source);
+ }
monitor.worked(1);
// Step 3: ensure containing folder exists...