Fixes an issue with UTF-8 symbols in translated strings

This commit is contained in:
Kristian Knarvik 2022-01-15 19:01:20 +01:00
parent 7be3717530
commit 6f3829f44f

View File

@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
/** /**
* A helper class for dealing with files * A helper class for dealing with files
@ -16,12 +18,12 @@ public class FileHelper {
* @return <p>A buffered read for reading the file</p> * @return <p>A buffered read for reading the file</p>
* @throws FileNotFoundException <p>If unable to get an input stream for the given file</p> * @throws FileNotFoundException <p>If unable to get an input stream for the given file</p>
*/ */
public static BufferedReader getBufferedReaderForInternalFile(String file) throws FileNotFoundException { public static BufferedReader getBufferedReaderForInternalFile(String file) throws FileNotFoundException, UnsupportedEncodingException {
InputStream inputStream = FileHelper.class.getResourceAsStream(file); InputStream inputStream = FileHelper.class.getResourceAsStream(file);
if (inputStream == null) { if (inputStream == null) {
throw new FileNotFoundException("Unable to read the given file"); throw new FileNotFoundException("Unable to read the given file");
} }
return new BufferedReader(new InputStreamReader(inputStream)); return new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
} }
} }