Skip to content

Commit 9089fec

Browse files
author
Federico Fissore
committed
Windows: working on reg query encoding issue #3360. German encoding is Cp852
1 parent f16bbaa commit 9089fec

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

app/test/processing/app/windows/RegQueryParserTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package processing.app.windows;
22

33
import org.junit.Test;
4+
import processing.app.helpers.FileUtils;
5+
6+
import java.io.File;
47

58
import static org.junit.Assert.assertEquals;
69

@@ -39,4 +42,12 @@ public void testRegQueryParserXP() throws Exception {
3942
assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath);
4043
}
4144

45+
@Test
46+
public void testRegQueryParserGerman() throws Exception {
47+
String output = FileUtils.readFileToString(new File(RegQueryParserTest.class.getResource("german.reg.query.output.txt").getFile()), "Cp852");
48+
49+
String folderPath = new RegQueryParser(output).getValueOfKey();
50+
assertEquals("C:\\Users\\René\\AppData\\Roaming", folderPath);
51+
}
52+
4253
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3+
AppData REG_SZ C:\Users\Ren�\AppData\Roaming
4+

arduino-core/src/processing/app/helpers/FileUtils.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ public static boolean isSCCSFolder(File file) {
177177
}
178178

179179
public static String readFileToString(File file) throws IOException {
180+
return readFileToString(file, "UTF-8");
181+
}
182+
183+
public static String readFileToString(File file, String encoding) throws IOException {
180184
BufferedReader reader = null;
181185
try {
182-
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
186+
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
183187
StringBuilder sb = new StringBuilder();
184188
String line;
185189
while ((line = reader.readLine()) != null) {

0 commit comments

Comments
 (0)