From bafd17e14f610511cd7a191223a3561b1602892a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 17 Apr 2016 14:28:15 +0100 Subject: Read non-ASCII source files correctly --- src/main/java/org/zwobble/couscous/frontends/java/JavaParser.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaParser.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaParser.java index e97d853..ceddf48 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaParser.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaParser.java @@ -1,6 +1,5 @@ package org.zwobble.couscous.frontends.java; -import com.google.common.base.Charsets; import com.google.common.collect.Iterables; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.dom.AST; @@ -8,8 +7,6 @@ import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.CompilationUnit; import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; import java.nio.file.Files; import java.nio.file.Path; import java.util.Hashtable; @@ -51,8 +48,7 @@ public class JavaParser { Iterables.toArray(transform(asList(sourcePathArguments), argument -> "UTF-8"), String.class), false); final byte[] javaFileBytes = Files.readAllBytes(sourcePath); - CharBuffer source = Charsets.UTF_8.decode(ByteBuffer.wrap(javaFileBytes)); - parser.setSource(source.array()); + parser.setSource(new String(javaFileBytes, "UTF-8").toCharArray()); return (CompilationUnit)parser.createAST(null); } -} \ No newline at end of file +} -- cgit v1.2.3