diff --git a/app/test/processing/app/windows/RegQueryParserTest.java b/app/test/processing/app/windows/RegQueryParserTest.java index 469f4db53..de26ae369 100644 --- a/app/test/processing/app/windows/RegQueryParserTest.java +++ b/app/test/processing/app/windows/RegQueryParserTest.java @@ -1,6 +1,9 @@ package processing.app.windows; import org.junit.Test; +import processing.app.helpers.FileUtils; + +import java.io.File; import static org.junit.Assert.assertEquals; @@ -39,4 +42,12 @@ public class RegQueryParserTest { assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath); } + @Test + public void testRegQueryParserGerman() throws Exception { + String output = FileUtils.readFileToString(new File(RegQueryParserTest.class.getResource("german.reg.query.output.txt").getFile()), "Cp852"); + + String folderPath = new RegQueryParser(output).getValueOfKey(); + assertEquals("C:\\Users\\RenĂ©\\AppData\\Roaming", folderPath); + } + } diff --git a/app/test/processing/app/windows/german.reg.query.output.txt b/app/test/processing/app/windows/german.reg.query.output.txt new file mode 100644 index 000000000..e5caffde3 --- /dev/null +++ b/app/test/processing/app/windows/german.reg.query.output.txt @@ -0,0 +1,4 @@ + +HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders + AppData REG_SZ C:\Users\Ren‚\AppData\Roaming + diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index fdc0b2570..981d3cb69 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -177,9 +177,13 @@ public class FileUtils { } public static String readFileToString(File file) throws IOException { + return readFileToString(file, "UTF-8"); + } + + public static String readFileToString(File file, String encoding) throws IOException { BufferedReader reader = null; try { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) {