Fix: Special unicode chars breaking on controls.

Turns out UTF 8 was not always enforced
This commit is contained in:
Boulay Mathias 2023-01-25 23:10:29 +01:00
parent 843e13bd6b
commit dfc36ab2b2

View File

@ -5,18 +5,23 @@ import com.google.gson.JsonSyntaxException;
import net.kdt.pojavlaunch.LwjglGlfwKeycode; import net.kdt.pojavlaunch.LwjglGlfwKeycode;
import net.kdt.pojavlaunch.Tools; import net.kdt.pojavlaunch.Tools;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.lwjgl.glfw.CallbackBridge; import org.lwjgl.glfw.CallbackBridge;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
public class LayoutConverter { public class LayoutConverter {
public static boolean convertLookType = false; //false = flat; true = classic public static boolean convertLookType = false; //false = flat; true = classic
public static CustomControls loadAndConvertIfNecessary(String jsonPath) throws IOException, JsonSyntaxException { public static CustomControls loadAndConvertIfNecessary(String jsonPath) throws IOException, JsonSyntaxException {
String jsonLayoutData = Tools.read(jsonPath);
String jsonLayoutData = IOUtils.toString(new InputStreamReader(new FileInputStream(jsonPath), StandardCharsets.UTF_8));
try { try {
JSONObject layoutJobj = new JSONObject(jsonLayoutData); JSONObject layoutJobj = new JSONObject(jsonLayoutData);