chisel-bootcamp
chisel-bootcamp copied to clipboard
java.nio.charset.MalformedInputException: Input length = 1
when i run code "visualize(() => new MovingAverage3(8))" in "0_demo.ipynb",i got a error that "dot" isn't exist. And then i installed graphviz 2.47.0 win64 for win10.I run this command again,and got a error "java.nio.charset.MalformedInputException: Input length = 1"
detail logs:
java.nio.charset.MalformedInputException: Input length = 1
java.nio.charset.CoderResult.throwException(CoderResult.java:281)
sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
java.io.InputStreamReader.read(InputStreamReader.java:184)
java.io.BufferedReader.read1(BufferedReader.java:210)
java.io.BufferedReader.read(BufferedReader.java:286)
java.io.Reader.read(Reader.java:140)
scala.io.BufferedSource.mkString(BufferedSource.scala:98)
firrtl.FileUtils$.getText(FileUtils.scala:130)
firrtl.FileUtils$.getText(FileUtils.scala:121)
ammonite.$file.dummy.source.load$minusivy_2$Helper.generateVisualizations(Main.sc:149)
ammonite.$file.dummy.source.load$minusivy_2$Helper.visualize(Main.sc:159)
ammonite.$sess.cmd3$Helper.
same phenomenon this line : val svgModuleText = FileUtils.getText(moduleView)
I see the same issue...
I see this issue as well. This is when running the demo in chisel-bootcamp.
Hi! I have solved the issue.
The issue is caused by the encoding format. In Windows, the default encoding setting is GBK
(for Chinese users). So the JVM would read files in GBK
format. The codes that caused the issue come from chisel-bootcamp-master\source\load-ivy.sc
and are:
val svgModuleText = FileUtils.getText(moduleView)
val svgInstanceText = FileUtils.getText(instanceView)
moduleView
and instanceView
are two .svg
files and their encoding format is UTF-8
, which causes an error when JVM loads these files.
To solve the problem, we need to specify the encoding of JVM by setting the system environment variable %JAVA_TOOL_OPTIONS%
to -Dfile.encoding=UTF-8
. After that, reboot your system.
You can examine your JVM encoding with this codes
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
class Test {
public static void main(String[] args) {
System.out.println("Default Charset=" + Charset.defaultCharset());
System.out.println("file.encoding=" + System.getProperty("file.encoding"));
System.out.println("Default Charset=" + Charset.defaultCharset());
System.out.println("Default Charset in Use=" + getDefaultCharSet());
}
private static String getDefaultCharSet() {
OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream());
String enc = writer.getEncoding();
return enc;
}
}
Here are my outputs:
Confirm it works after doing what @ranshuo-ICer suggested: