1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-17 11:54:33 +01:00

Windows: working on reg query encoding issue . German encoding is Cp852

This commit is contained in:
Federico Fissore 2015-06-19 17:38:10 +02:00
parent f16bbaa91d
commit 9089fecbe4
3 changed files with 20 additions and 1 deletions
app/test/processing/app/windows
arduino-core/src/processing/app/helpers

@ -1,6 +1,9 @@
package processing.app.windows; package processing.app.windows;
import org.junit.Test; import org.junit.Test;
import processing.app.helpers.FileUtils;
import java.io.File;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -39,4 +42,12 @@ public class RegQueryParserTest {
assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath); 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);
}
} }

@ -0,0 +1,4 @@
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
AppData REG_SZ C:\Users\Ren\AppData\Roaming

@ -177,9 +177,13 @@ public class FileUtils {
} }
public static String readFileToString(File file) throws IOException { 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; BufferedReader reader = null;
try { try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {