X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2FresourceFiles%2FResourceFile.java;h=a847dbee130e61fb4ab6ea84a17afa14020ee9f8;hp=c7e1f22b14ccf58b173ab2b323cad58a4955346b;hb=8a9adec5741f3cd81972129919d76646f825d2f5;hpb=2987cc1807e22e7b6856a8966f0d92b31c343415 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java index c7e1f22b1..a847dbee1 100644 --- a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java @@ -6,6 +6,7 @@ import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.net.URL; +import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -19,6 +20,8 @@ import freemarker.template.DefaultObjectWrapper; import freemarker.template.Template; public class ResourceFile implements IResourceFile { + private final static Charset UTF8 = Charset.forName("UTF-8"); + String packageName; String className; List resources; @@ -88,8 +91,8 @@ public class ResourceFile implements IResourceFile { @Override public InputStream getContent() { StringWriter writer = new StringWriter(); - write(writer); - return new ByteArrayInputStream(writer.toString().replace("\r\n", "\n").getBytes()); + write(String.format("%n").length() == 1 ? new FilterCRWriter(writer) : writer); + return new ByteArrayInputStream(writer.toString().getBytes(UTF8)); } /* (non-Javadoc) @@ -105,11 +108,12 @@ public class ResourceFile implements IResourceFile { } public static void main(String[] args) { - ResourceRef Foo = new ResourceRef("Foo", "http://www.dsf.sdf/Foo"); + /*ResourceRef Foo = new ResourceRef("Foo", "http://www.dsf.sdf/Foo"); ResourceRef Bar = new ResourceRef("Foo", "http://www.dsf.sdf/Bar"); Bar.deprecated = true; new ResourceFile("org.simantics.graph", "Testi", Arrays.asList( Foo, Bar - )).write(new OutputStreamWriter(System.out)); + )).write(new OutputStreamWriter(System.out));*/ + System.out.println(String.format("%n").length()); } }