specify utf8 encoding
this should fix the following known bugs: - putting a U+2019 in the config causes it to become corrupted and ~double in size every launch - scripts become assembled incorrectly and the nbsp after your name in the chatbox becomes incorrect - the feed panel doesn't show emoji
This commit is contained in:
@@ -28,6 +28,7 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -58,7 +59,7 @@ class SessionClient
|
||||
ResponseBody body = response.body();
|
||||
|
||||
InputStream in = body.byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), UUID.class);
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), UUID.class);
|
||||
}
|
||||
catch (JsonParseException | IllegalArgumentException ex) // UUID.fromString can throw IllegalArgumentException
|
||||
{
|
||||
|
||||
@@ -27,9 +27,12 @@ package net.runelite.client.account;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import javax.inject.Inject;
|
||||
@@ -91,7 +94,7 @@ public class SessionManager
|
||||
|
||||
try (FileInputStream in = new FileInputStream(sessionFile))
|
||||
{
|
||||
session = new Gson().fromJson(new InputStreamReader(in), AccountSession.class);
|
||||
session = new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), AccountSession.class);
|
||||
|
||||
log.debug("Loaded session for {}", session.getUsername());
|
||||
}
|
||||
@@ -119,7 +122,7 @@ public class SessionManager
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileWriter fw = new FileWriter(sessionFile))
|
||||
try (Writer fw = new OutputStreamWriter(new FileOutputStream(sessionFile), StandardCharsets.UTF_8))
|
||||
{
|
||||
new Gson().toJson(accountSession, fw);
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.AtomicMoveNotSupportedException;
|
||||
import java.nio.file.Files;
|
||||
@@ -224,7 +223,7 @@ public class ConfigManager
|
||||
final Properties properties = new Properties();
|
||||
try (FileInputStream in = new FileInputStream(propertiesFile))
|
||||
{
|
||||
properties.load(new InputStreamReader(in, Charset.forName("UTF-8")));
|
||||
properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -295,7 +294,7 @@ public class ConfigManager
|
||||
|
||||
try (FileInputStream in = new FileInputStream(propertiesFile))
|
||||
{
|
||||
properties.load(new InputStreamReader(in, Charset.forName("UTF-8")));
|
||||
properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -53,7 +54,7 @@ public class ItemVariationMapping
|
||||
};
|
||||
|
||||
final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json");
|
||||
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData), typeToken.getType());
|
||||
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData, StandardCharsets.UTF_8), typeToken.getType());
|
||||
|
||||
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
|
||||
ImmutableMultimap.Builder<Integer, Integer> invertedBuilder = new ImmutableMultimap.Builder<>();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.plugins.gpu;
|
||||
|
||||
import com.jogamp.opengl.GL4;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
class GLUtil
|
||||
{
|
||||
@@ -63,14 +64,14 @@ class GLUtil
|
||||
{
|
||||
byte[] err = new byte[ERR_LEN];
|
||||
gl.glGetShaderInfoLog(shader, ERR_LEN, buf, 0, err, 0);
|
||||
return new String(err, 0, buf[0]);
|
||||
return new String(err, 0, buf[0], StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
static String glGetProgramInfoLog(GL4 gl, int program)
|
||||
{
|
||||
byte[] err = new byte[ERR_LEN];
|
||||
gl.glGetProgramInfoLog(program, ERR_LEN, buf, 0, err, 0);
|
||||
return new String(err, 0, buf[0]);
|
||||
return new String(err, 0, buf[0], StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
static int glGenVertexArrays(GL4 gl)
|
||||
|
||||
@@ -24,10 +24,13 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.gpu.template;
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Template
|
||||
@@ -92,7 +95,13 @@ public class Template
|
||||
|
||||
private static String inputStreamToString(InputStream in)
|
||||
{
|
||||
Scanner scanner = new Scanner(in).useDelimiter("\\A");
|
||||
return scanner.next();
|
||||
try
|
||||
{
|
||||
return CharStreams.toString(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.skillcalculator;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.runelite.client.plugins.skillcalculator.beans.SkillData;
|
||||
@@ -43,7 +44,7 @@ class CacheSkillData
|
||||
}
|
||||
|
||||
InputStream skillDataFile = SkillCalculatorPlugin.class.getResourceAsStream(dataFile);
|
||||
SkillData skillData = new Gson().fromJson(new InputStreamReader(skillDataFile), SkillData.class);
|
||||
SkillData skillData = new Gson().fromJson(new InputStreamReader(skillDataFile, StandardCharsets.UTF_8), SkillData.class);
|
||||
|
||||
cache.put(dataFile, skillData);
|
||||
return skillData;
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -88,7 +89,7 @@ class Skybox
|
||||
|
||||
public Skybox(InputStream is, String filename) throws IOException
|
||||
{
|
||||
this(new InputStreamReader(is), filename);
|
||||
this(new InputStreamReader(is, StandardCharsets.UTF_8), filename);
|
||||
}
|
||||
|
||||
public Skybox(Reader reader, String filename) throws IOException
|
||||
|
||||
@@ -26,6 +26,7 @@ package net.runelite.client.plugins.twitch;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Provides;
|
||||
import java.io.IOException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
@@ -218,8 +219,15 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
|
||||
return true;
|
||||
}
|
||||
|
||||
twitchIRCClient.privmsg(message);
|
||||
addChatMessage(twitchConfig.username(), message);
|
||||
try
|
||||
{
|
||||
twitchIRCClient.privmsg(message);
|
||||
addChatMessage(twitchConfig.username(), message);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.warn("failed to send message", e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ package net.runelite.client.plugins.twitch.irc;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -48,7 +50,7 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
|
||||
private Socket socket;
|
||||
private BufferedReader in;
|
||||
private PrintWriter out;
|
||||
private Writer out;
|
||||
private long last;
|
||||
private boolean pingSent;
|
||||
|
||||
@@ -86,8 +88,8 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
socket = socketFactory.createSocket(HOST, PORT);
|
||||
socket.setSoTimeout(READ_TIMEOUT);
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
out = new PrintWriter(socket.getOutputStream());
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
out = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -95,11 +97,11 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
return;
|
||||
}
|
||||
|
||||
register(username, password);
|
||||
join(channel);
|
||||
|
||||
try
|
||||
{
|
||||
register(username, password);
|
||||
join(channel);
|
||||
|
||||
String line;
|
||||
|
||||
while ((line = read()) != null)
|
||||
@@ -162,8 +164,16 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
|
||||
if (!pingSent && System.currentTimeMillis() - last >= PING_TIMEOUT)
|
||||
{
|
||||
ping("twitch");
|
||||
pingSent = true;
|
||||
try
|
||||
{
|
||||
ping("twitch");
|
||||
pingSent = true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.debug("Ping failure, disconnecting.", e);
|
||||
close();
|
||||
}
|
||||
}
|
||||
else if (pingSent)
|
||||
{
|
||||
@@ -172,29 +182,29 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
|
||||
}
|
||||
}
|
||||
|
||||
private void register(String username, String oauth)
|
||||
private void register(String username, String oauth) throws IOException
|
||||
{
|
||||
send("CAP", "REQ", "twitch.tv/commands twitch.tv/tags");
|
||||
send("PASS", oauth);
|
||||
send("NICK", username);
|
||||
}
|
||||
|
||||
private void join(String channel)
|
||||
private void join(String channel) throws IOException
|
||||
{
|
||||
send("JOIN", channel);
|
||||
}
|
||||
|
||||
private void ping(String destination)
|
||||
private void ping(String destination) throws IOException
|
||||
{
|
||||
send("PING", destination);
|
||||
}
|
||||
|
||||
public void privmsg(String message)
|
||||
public void privmsg(String message) throws IOException
|
||||
{
|
||||
send("PRIVMSG", channel, message);
|
||||
}
|
||||
|
||||
private void send(String command, String... args)
|
||||
private void send(String command, String... args) throws IOException
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(command);
|
||||
|
||||
@@ -28,6 +28,7 @@ package net.runelite.client.rs;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.AllArgsConstructor;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -55,7 +56,7 @@ class ClientConfigLoader
|
||||
}
|
||||
|
||||
String str;
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream()));
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream(), StandardCharsets.UTF_8));
|
||||
while ((str = in.readLine()) != null)
|
||||
{
|
||||
int idx = str.indexOf('=');
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -215,7 +216,7 @@ public class ImageCapture
|
||||
try (InputStream in = response.body().byteStream())
|
||||
{
|
||||
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
|
||||
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
|
||||
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), ImageUploadResponse.class);
|
||||
|
||||
if (imageUploadResponse.isSuccess())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user