1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Windows: working on reg query encoding issue #3360. 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

View File

@ -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);
}
}

View File

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

View File

@ -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) {